This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Gobot1234
Recipients Gobot1234, gvanrossum, kj
Date 2022-02-14.01:39:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644802762.6.0.86533921793.issue46743@roundup.psfhosted.org>
In-reply-to
Content
```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.
History
Date User Action Args
2022-02-14 01:39:22Gobot1234setrecipients: + Gobot1234, gvanrossum, kj
2022-02-14 01:39:22Gobot1234setmessageid: <1644802762.6.0.86533921793.issue46743@roundup.psfhosted.org>
2022-02-14 01:39:22Gobot1234linkissue46743 messages
2022-02-14 01:39:22Gobot1234create