[issue46743] Enable usage of object.__orig_class__ in __init__
Gobot1234
report at bugs.python.org
Sun Feb 13 20:39:22 EST 2022
Gobot1234 <gobot1234yt at gmail.com> added the comment:
```py
class DefaultBox(Generic[T]):
def __init__(self, value: T | None = None):
self.value = (
value if value is not None else # the arg
self.__orig_class__.__args__[0]() # or the default for the type argument
)
int_box = DefaultBox[int]()
print(int_box.value) # should print 0
str_box = DefaultBox[str](value="this")
print(str_box.value) # should print this
```
Currently this doesn't work, but I really think it should.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46743>
_______________________________________
More information about the Python-bugs-list
mailing list