[Biopython-dev] Bio.SeqIO

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

Peter wrote:
> Michiel de Hoon wrote:
>> 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.
> We (or the user) might well change the records - in particular, they 
> might add MORE records.  How about this:
Still, it doesn't matter, since we're making a copy of records via the 
list function. So self._records is not the same as the records default 
argument in the __init__ function. If a user adds more records, they 
will end up in the object-specific self._records.


More information about the Biopython-dev mailing list