Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90628

Re: a python pitfall

References <CAB1ii-cFpbmdjQfRA_J3TBUZ+Gx8e8vLvqTLo2R-f0ygkykV1A@mail.gmail.com>
Date 2015-05-14 13:55 -0500
Subject Re: a python pitfall
From Skip Montanaro <skip.montanaro@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15.1431629731.17265.python-list@python.org> (permalink)

Show all headers | View raw


> I saw the following example at
> http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments
> and did not believe the output produced and had to try it for myself....

Pylint (and perhaps other Python "linters") would, I think, warn you
that you were using a mutable object as a default. It's more obvious
that the list is being reused if you call foo with different values
each time.

Skip

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: a python pitfall Skip Montanaro <skip.montanaro@gmail.com> - 2015-05-14 13:55 -0500

csiph-web