I'm wrong or Will we fix the ducks limp?
cs at zip.com.au
cs at zip.com.au
Sun Jun 5 18:41:34 EDT 2016
On 03Jun2016 16:09, Sayth Renshaw <flebber.crue at gmail.com> wrote:
>> (By the way, the "pf = pf.append(thing)" construction is weird.
>> All you need is pf.append(thing).)
>
>I got the pf = pf.append(thing) from doing pandas because in pandas its not an
>inplace function.
In Python this doesn't do what you think. The convention with most Python
methods is that methods which perform an in-place action return None, which
means the above assignment will unbind "pf", binding it to None instead.
BTW, the short answer to why you can't just say pf.append(thing) and have "pf"
be a list is that ".append" is not _inherently_ a list method i.e. the langauge
does not specify that name as special. You can have another type where .append
does somehing else. Therefore, the deduction that pf is uspposed to be a list
may not be made.
Cheers,
Cameron Simpson <cs at zip.com.au>
More information about the Python-list
mailing list