variable & scoping question.

J. Cliff Dyer jcd at sdf.lonestar.org
Mon Aug 10 14:47:19 EDT 2009


On Mon, 2009-08-10 at 08:46 -0700, Cornelius Keller wrote:
> On 10 Aug., 17:12, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> > Cornelius Keller wrote:
> [snip]
> >
> > http://effbot.org/zone/default-values.htm
> >
> > Diez
> 
> Ok thank you.
> I' understand now why.
> I still think this is very confusing, because default values don't
> behave like most people would expect without reading the docs.
> 
> - Cornelius

You are correct.  This is confusing at first blush.  The important thing
to remember is: *don't do that.*  Learn the pythonic workaround of using
None in your parameters whenever you want a default empty list, and
don't let it bother you too much.  Overall, python is a remarkably well
designed language.  This is one of the relatively rare warts that crept
in because it enables a broader cleanliness of design.

Cheers,
Cliff





More information about the Python-list mailing list