[Python-Dev] Is static typing still optional? (original) (raw)
Eric V. Smith eric at trueblade.com
Thu Dec 21 09:23:12 EST 2017
- Previous message (by thread): [Python-Dev] Is static typing still optional?
- Next message (by thread): [Python-Dev] Is static typing still optional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] Is static typing still optional?
- Next message (by thread): [Python-Dev] Is static typing still optional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]