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

Eric Snow ericsnowcurrently at gmail.com
Wed Aug 10 19:04:01 EDT 2016


On Wed, Aug 10, 2016 at 11:56 AM, Guido van Rossum <guido at python.org> wrote:
> Sounds like you're thinking with your runtime hat on, not your type checker
> hat. :-)
>
> On Tue, Aug 9, 2016 at 9:46 PM, Neil Girdhar <mistersheik at gmail.com> wrote:
>>
>> With PEP 520 accepted, would it be possible to iterate over
>> __definition_order__?

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.

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.)

-eric


More information about the Python-ideas mailing list