On Tue, 18 Jul 2023 at 19:02, Dom Grigonis <dom.grigo...@gmail.com> wrote:
>
> Thank you.
>
> I meant “superset of 671, not 505”…
>
> One question:
>
> def bar(a => None);
>     return foo(a)
>
> def foo(a => object()):
>     return a
>
> How would I force foo’s default from bar’s call?

That's a known-hard problem. The best way is probably to use *a,**kw
and only pass the args you get, but that doesn't always work.

> Would something like this work?
>
> def foo(a => object() if a is None else a):
>     return a

Yyyyyyes, but now you're defining that a could be None, so you may as
well go with the classic idiom:

def foo(a=None):
    if a is None: a = object()

The point of default argument expressions is that you DON'T need to
accept a fake default.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RYMC4J53X6RO7RCBXFYWOYLVKQ3Z64BT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to