A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/063406.html below:

Bug with [] as default value in functions?

Bug with [] as default value in functions? - bug.py (0/1)Dinu Gherman dinu at reportlab.com
Thu Apr 12 07:49:23 EDT 2001
Hi,

I noticed a very strange behaviour: I've got a recursive function like
this:

  foo(spam, eggs=[]):
    ...
    return foo(spam, eggs=eggs

where the default argument for eggs, the empty list, is *empty* for
the top-level call only when it is explicitly provided with the func-
tion call like this:

  bar = foo(mySpam, eggs=[])

I've attached a more lengthy example showing, I hope, rather pre-
cisely what I mean.

Is this a bug or just a lack of understanding of recursion and name
spaces, delicate as they are, in my brain??

Regards,

Dinu


-- 
Dinu C. Gherman
dinu at reportlab dot com
http://www.reportlab.com
................................................................
"The only possible values [for quality] are 'excellent' and 'in-
sanely excellent', depending on whether lives are at stake or 
not. Otherwise you don't enjoy your work, you don't work well, 
and the project goes down the drain." 
                    (Kent Beck, "Extreme Programming Explained")

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4