Hi,
by chance I looked into the impl of inspect.getmembers today and was
slightly shocked:
def getmembers(object, predicate=None):
"""Return all members of an object as (name, value) pairs sorted by
name.
Optionally, only return members that satisfy a given predicate."""
results = []
for key in dir(object):
According to
http://docs.python.org/library/functions.html
"""
Note Because dir() is supplied primarily as a convenience for use at an
interactive prompt, it tries to supply an interesting set of names more
than it tries to supply a rigorously or consistently defined set of
names, and its detailed behavior may change across releases. For
example, metaclass attributes are not in the result list when the
argument is a class.
"""
This is a bit inconsistent, and I think the standard lib should be the
best example for clean code that is consistent with the docs.
Is the usage of dir() correct in this context or is the doc right?
It would be nice to add a sentence of clarification if the use of
dir() is in fact the correct way to implement inspect.
cheers - chris
--
Christian Tismer :^)<mailto:tis...@stackless.com>
tismerysoft GmbH : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* http://starship.python.net/
14482 Potsdam : PGP key -> http://pgp.uni-mainz.de
work +49 173 24 18 776 mobile +49 173 24 18 776 fax n.a.
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com