Why the result

Fredrik Lundh fredrik at pythonware.com
Fri Oct 20 05:20:25 EDT 2006


"HYRY" <zhangry at feng.co.jp> wrote:

> Why the third print stement output "'comments': [(1, 2, 3)]", I think
> it should be [].

default arguments are calculated once.  for details, see the tutorial

  http://docs.python.org/tut/node6.html#SECTION006710000000000000000

and the FAQ:

  http://pyfaq.infogami.com/why-are-default-values-shared-between-objects

and the language reference:

  http://python.org/doc/ref/function.html
  http://pyref.infogami.com/def

</F> 






More information about the Python-list mailing list