Default annotations for variables

Kirill Balunov kirillbalunov at gmail.com
Wed Dec 27 05:41:10 EST 2017


Will there be any implications (or is it possible) if all variables will
have an attribute *something like* `__type__` which by default will be
initialized to *something like* `AnyType`. So in the case `x = 12` will be
equivalent to `x: AnyType = 12`.

x: int
x = 12
x.__type__ # int

a, b = 11, 12
a.__type__  # AnyType
b.__type__  # AnyType

And also in this case:

class Dummy:
    a: int
    b: float
    c = []

Dummy.__annotations__  # will be {'a': int, 'b': float, 'c': AnyType}


While I ask purely out of curiosity, I think this is not an off-topic for
python-list.

With kind regards, -gdg



More information about the Python-list mailing list