[Python-ideas] proto-PEP: Fixing Non-constant Default Arguments

Josiah Carlson jcarlson at uci.edu
Tue Jan 30 23:31:36 CET 2007


Roman Susi <rnd at onego.ru> wrote:
>     def foo(x, y, z, bar=Missing, qux=Missing):
>         if baz is Missing:
>             baz = []
>         #code

With the proper definition of Missing, the above is fine, and is more or
less creating a new 'None' value.

> or even:
> 
>     def foo(x, y, z, bar=, qux=):
>         if baz is Missing:
>             baz = []
>         #code
> 
> at least, it doesn't require decorators, is backward compatible
> (hopefully no grammar conflicts in there), reads as English.

The above with a missing value for a default *is not* backwards
compatible with previous Pythons.  New syntax is, by definition, not
backwards compatible.

 - Josiah




More information about the Python-ideas mailing list