[Python-Dev] q about default args

Jeremy Hylton jeremy@alum.mit.edu
Wed, 21 Aug 2002 15:03:50 -0400


>>>>> "SK" == Stepan Koltsov <yozh@mx1.ru> writes:

  SK> 2. Currently, default arguments are like static function
  SK>    variables,
  SK> defined in the function parameter list! That is wrong.

No, it's not.  The Python language definition is completely clear on
the semantics of default arguments.  They are evaluated at function
definition time and stored like static function variables.

  SK> 4. Again: I dislike code like

  SK> ---

  SK> def f(l=None):
  SK>     if l is None:
  SK>         l = []
  SK>     ...

  SK> ===

I don't see anything wrong with this code.

  SK> 5. I asked my friend (also big Python fan): why the current
  SK> behaviour is correct?  his answer was: "the curren behaviour is
  SK> correct, becausethat is the way it was done in the first place
  SK> :-) ..." I don't see any advantages of the current style, and
  SK> lack of advantages is advantage of new style :-)

Even if I liked the semantics you propose, it would create enormous
pain to change the language semantics here.

You'll have to work a lot harder on motivation if you want us to fix
something that isn't broken :-).

Jeremy