Hi Serhiy

Thank you for so clearly explaining how names get passed to function and
class constructors.

You also wrote:

> We do not have generalized way to call arbitrary constructor with
> automatically passing __name__, __qualname__ and __module__. And it would
> be convenient.
>
>     create namedtuple Point(x, y, z=0)
>      [further examples snipped]


We can already do something similar by writing (not tested)
    class Point(Hack): namedtuple = lambda x, y, z=0: None
provided Hack has a suitable value.

I don't see a way to do much better than this, without introducing a new
language keyword. For example allow
    signature(x, y, z=0)
to be an EXPRESSION that returns a function signature.

By the way,
    class Point(Hack): def namedtuple(x, y, z=0): pass
gives a syntax error at 'def'.
-- 
Jonathan
_______________________________________________
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/CRSD2XZXJTRD4VNPRAUAFPKBELMA2FG3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to