[Biopython-dev] Bio.SeqIO

Michiel de Hoon mdehoon at c2b2.columbia.edu
Mon Feb 26 09:53:46 UTC 2007


Alex Griffing wrote:
> 
>> The easiest way to accomplish this might be to change the __init__ of 
>> the Alignment class from
>>
>> def __init__(self, alphabet)
>>
>> to
>>
>> def __init__(self, alphabet, records=[])
>>   
> 
> Does this apply here?
> http://www.python.org/doc/faq/general.html#why-are-default-values-shared-between-objects 
> 
In theory, yes, but since we won't be modifying records it doesn't 
matter. The full function would look like:

     def __init__(self, alphabet, records=[]):
         self._alphabet = alphabet
         self._records = list(records)

The "list" is necessary since the user may pass an iterator for records 
instead of a list.

--Michiel.




More information about the Biopython-dev mailing list