Odd Errors

Nathan Seese uninverted at lavabit.com
Mon Sep 29 02:58:35 CEST 2008


> On Sep 28, 7:13 pm, alex23 <wuwe... at gmail.com> wrote:
>> The problem is with this:
>>
>> >         lines = lines.append(inLine)
>>
>> The append method of a list modifies the list in-place, it doesn't
>> return a copy of the list with the new element appended. In fact, it
>> returns None, which it then attaches the label 'lines' to, so the next
>> iteration through it tries to call None.append...
>>
>> Replace the line with:
>>
>>     lines.append(inLine)
> 
> Do you ever want to scream from the rooftops, "'append' operates by
> side-effect!"?

Ah! Thanks, especially for the quick response.



More information about the Python-list mailing list