Message413205
```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. |
|
Date |
User |
Action |
Args |
2022-02-14 01:39:22 | Gobot1234 | set | recipients:
+ Gobot1234, gvanrossum, kj |
2022-02-14 01:39:22 | Gobot1234 | set | messageid: <1644802762.6.0.86533921793.issue46743@roundup.psfhosted.org> |
2022-02-14 01:39:22 | Gobot1234 | link | issue46743 messages |
2022-02-14 01:39:22 | Gobot1234 | create | |
|