Eric V. Smith <e...@trueblade.com> added the comment:

I'm not sure I understand the distinction. You have to look through everything 
in `__dict__`, then exclude those things that are any type of field (so, real 
fields or pseudo-fields). Those are the things that are in `__annotations__`, 
anyway.

The trick is what else to exclude.  In this class:

class C:
    x: int = 0
    y = 0

    def func(self): pass

    @staticmethod
    def staticmeth() : pass

    @classmethod
    def classmeth(cls) : pass

    @property
    def prop(self): pass

These are the non-callables:

print([k for k in C.__dict__ if not callable(getattr(C, k))])

['__module__', '__annotations__', 'x', 'y', 'prop', '__dict__', '__weakref__', 
'__doc__']

How do we only pick out `y` and probably `prop`, and ignore the rest, without 
being overly fragile to new things being added? I guess ignoring dunders and 
things in `__annotations__`. Is that close enough?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32428>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to