Steven D'Aprano wrote:
> However it is easy to use introspection to get what you need.
So just for completeness sake, what Thomas probably wants is the following:
from types import MethodType
def attributes(obj):
return [attr for attr in dir(obj)
if not attr.startswith('__')
and not isinstance(getattr(obj, attr), MethodType)]
# Example:
class Parrot(object):
ATTR = None
join = ''.join # callable, but not a method of Parrot
def aMethod(self):
return ATTR
print attributes(Parrot)
# this gives: ['ATTR', 'join']
--
http://mail.python.org/mailman/listinfo/python-list