[Python-ideas] Optional parameters without default value

Serhiy Storchaka storchaka at gmail.com
Thu Mar 2 04:06:55 EST 2017


On 02.03.17 10:36, M.-A. Lemburg wrote:
> Why a new syntax ? Can't we just have a pre-defined sentinel
> singleton NoDefault and use that throughout the code (and also
> special case it in argument parsing/handling)?
>
> def get(store, key, default=NoDefault):
>     if store.exists(key):
>         return store.retrieve(key)
>     ...

This means adding a new syntax. NoDefault should be a keyword (we can 
reuse existing keyword couldn't be used in expression), and it should be 
accepted only in the specific context of declaring function parameter.




More information about the Python-ideas mailing list