Message4813

Author boisgera
Recipients boisgera
Date 2009-06-15.10:22:53
SpamBayes Score 8.24341e-14
Marked as misclassified No
Message-id <1245061374.57.0.788956448077.issue1376@psf.upfronthosting.co.za>
In-reply-to
Content
It seems natural that when 'name in dir(item)' holds, 'getattr(item,
name)' will work. The function inspect.classify_class_attrs for example
requires this property.

AFAICT, this invariant is violated when item is a Java class that
defines some 'getXXX' methods: 'XXX' will appear in dir(Class) but
getattr(Class, 'XXX') won't work. For example:

    >>> from java.lang import *
    >>> "class" in dir(String) # generated from getClass
    True
    >>> getattr(String, "class")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: instance attr: class
    >>> "bytes" in dir(String) # generated from getBytes
    True
    >>> getattr(String, "bytes")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: instance attr: bytes
History
Date User Action Args
2009-06-15 10:22:54boisgerasetrecipients: + boisgera
2009-06-15 10:22:54boisgerasetmessageid: <1245061374.57.0.788956448077.issue1376@psf.upfronthosting.co.za>
2009-06-15 10:22:54boisgeralinkissue1376 messages
2009-06-15 10:22:53boisgeracreate