24.10.21 15:20, Stephen J. Turnbull пише:
> What do you mean by "constructor" here?  Normally that word refers to
> methods that populate the attributes of instances (in Python, __init__
> and__new__).  But functions and methods don't have such, so you must
> mean something else?

They have. Both function and type classes have constructors and they are
called when a function or class is created. Values of __name__,
__qualname__ and __module__ attributes are directly or indirectly passed
to constructors.

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)
    create enum Mode(read, write, append)
    create NewType UserId(int)
    create TypeVar T

_______________________________________________
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/VIRQ44BQKO2ENNL42PCNCVHVLPZMTXYV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to