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

Reply via email to