Puzzled by list-appending behavior
Chris Angelico
rosuav at gmail.com
Thu May 26 23:24:24 EDT 2011
On Fri, May 27, 2011 at 11:59 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> def get(list, object):
> """Append object to a copy of list and return it."""
> return list + [object]
>
> For one or two line functions, I think that's perfectly reasonable.
> Anything more than that, I'd be getting nervous.
But even for something that short, why do it? Why not call the
parameter 'lst' or something? Shadowing with something completely
different is seldom going to give major advantage, and has the
potential to be quite confusing.
Chris Angelico
More information about the Python-list
mailing list