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