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 anthony
Recipients anthony
Date 2019-11-09.20:29:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573331378.39.0.720825104311.issue38758@roundup.psfhosted.org>
In-reply-to
Content
Given one of the motivations of @dataclass is to reduce boilerplate code then, in the context of @dataclass,

x: list = [] should be equal to x: list = field(default_factory=lambda: [])

The example in PEP 557 is not reasonable. It should be:

class D:
    def __init__(self, x=[]):
        self.x = x

That x = None works (without specifying a default factory, and is different from plain "x")  makes the whole "factory" argument even more bizarre. Why would a None Type work, but a List Type not?

I think either the behavior of this should be different or the docs should at address this more clearly.
History
Date User Action Args
2019-11-09 20:29:38anthonysetrecipients: + anthony
2019-11-09 20:29:38anthonysetmessageid: <1573331378.39.0.720825104311.issue38758@roundup.psfhosted.org>
2019-11-09 20:29:38anthonylinkissue38758 messages
2019-11-09 20:29:38anthonycreate