[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484

Guido van Rossum guido at python.org
Wed Aug 10 19:08:16 EDT 2016


On Wed, Aug 10, 2016 at 4:04 PM, Eric Snow <ericsnowcurrently at gmail.com>
wrote:
[...]
>
> Still, it would be really nice to be able to introspect a class's
> instance attributes at run-time.  A stdlib helper for that would be
> great, e.g. "inspect.get_inst_attrs(cls)".  At one point a few years
> back I wrote something like that derived from the signature of
> cls.__init__() and in the spirit of inspect.signature().  It turned
> out to be quite useful.
>

Yes, the proposal will store variable annotations for globals and for
classes in __annotations__ (one global, one per class). Just not for local
variables.


> Relatedly, it may make sense to recommend in PEP 8 that all instance
> attribute declarations in a class definition be grouped together and
> to do so right before the methods (right before __new__/__init__?).
> (...or disallow instance attribute declarations in the stdlib for
> now.)
>

Let's wait until we have some experience with how it's used before updating
PEP 8... :-)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160810/026f5610/attachment-0001.html>


More information about the Python-ideas mailing list