[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484
Daniel Moisset
dmoisset at machinalis.com
Thu Aug 4 10:12:11 EDT 2016
There's something I found a bit confusing in the runtime semantic of
defaults in your strawman proposal:
On Tue, Aug 2, 2016 at 11:09 PM, Guido van Rossum <guido at python.org> wrote:
> Agreed, we need to invent a workable proposal for this. Here's a strawman:
>
> - The default is an instance variable (backed by a class variable as
> default if there's an initial value)
> - To define a class variable, prefix the type with 'class`
>
> Example:
>
> class C:
> a: int # instance var
> b: List[int] = None # instance var
> c: class List[int] = [] # class var
>
>
>From that description I understand that after C is defined, C.__dict__ will
contain the {'c': []} mapping... where us the {'b': None} mapping stored?
what's the runtime semantics that get it to every created instance?
Or you are proposing that in runtime these are equivalent to "b, c = None,
[]" ? If that's the case, I find it misleading to call them "instance
variables" vs "class variables", given that those concepts are supposed to
have different runtime semantics, not just for the typechecker.
--
Daniel F. Moisset - UK Country Manager
www.machinalis.com
Skype: @dmoisset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160804/0ad4456a/attachment-0001.html>
More information about the Python-ideas
mailing list