Gobot1234 <[email protected]> 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 <[email protected]>
<https://bugs.python.org/issue46743>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com