[Python-ideas] proto-PEP: Fixing Non-constant Default Arguments
Georg Brandl
g.brandl at gmx.net
Tue Jan 30 21:17:55 CET 2007
Roman Susi schrieb:
> Chris Rebert wrote:
>> Jim Jewett wrote:
>>
>>>On 1/28/07, Chris Rebert <cvrebert at gmail.com> wrote:
>
> /skip/
>
>>>
>>>> def foo(bar=new baz):
>>>> #code
>>>
>>>This would be less bad.
>>>
>>>That said, I fear many new programmers would fail to understand when
>>>they needed new and when they didn't, so that in practice, it would be
>>>just optional random noise.
>>
>>
>> This is part of the reason I'm trying to avoid adding new syntax.
>> However, I assert that at least 'new' is clearer than the' x=None; if x
>
> But if you are concerned with the current None, there could be some
> other, new False value serving the same need, like:
>
> def foo(x, y, z, bar=Missing, qux=Missing):
> if baz is Missing:
> baz = []
> #code
>
> or even:
>
> def foo(x, y, z, bar=, qux=):
> if baz is Missing:
> baz = []
> #code
why not even
def foo(x, y, z, bar=..., qux=...):
if bar is Ellipsis:
# foo
;)
Georg
More information about the Python-ideas
mailing list