On 12/21/17 6:25 AM, Sven R. Kunze wrote: > On 21.12.2017 11:22, Terry Reedy wrote: >> >>>> @dataclass >>>> class C: >>>> a: int # integer field with no default >>>> b: float = 0.0 # float field with a default >>>> >>>> And the types will be recognized by type checkers such as mypy. >>>> >>>> And I think the non-typed examples should go first in the docs. >> > > I still don't understand why "I don't care" can be defined by "leaving out" > > @dataclass > class C: > b = 0.0 # float field with a default Because you can't know the order that x and y are defined in this example: class C: x: int y = 0 'x' is not in C.__dict__, and 'y' is not in C.__annotations__. Someone will suggest a metaclass, but that has its own problems. Mainly, interfering with other metaclasses. Eric. > > > For non-default fields, I like ellipsis too. > > Cheer, > Sven > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/eric%2Ba-python-dev%40trueblade.com >
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4