Bug? If not, how to work around it?
Alex Martelli
aleax at aleax.it
Thu Aug 7 13:28:57 EDT 2003
Michele Simionato wrote:
> Gonçalo Rodrigues <op73418 at mail.telepac.pt> wrote in message news:
>> So, is it a bug? In other words, should I open a bug report?
>>
>> With my best regards,
>> G. Rodrigues
>
> I would open a bug report; at the best this is a documentation bug,
I disagree that it's a documentation bug.
> since
> the fact that ___getattr__ is skipped by special methods is never
The language reference says:
""" A class can implement certain operations ... by defining methods
with special names. """
This is VERY explicit -- "__getattr__ is skipped" is false (the
__getattr__ a *metaclass* could define would indeed be used as
equivalent to the class defining methods) -- the _class_'s __getattr__
if any is irrelevant because it's used on class *instances* (as
the language reference also says a few pages later) and thus it's
not the *CLASS* that's defining "methods with special names" here.
If anything, a mention might be warranted that, for compatibility,
a bug is retained in old-style classes, whereby, in addition to the
class's ability to define methods with special names, any old-style
class INSTANCE may also define them (e.g. through __getattr__) in
contrast with what the docs have just said about the general case.
I do suspect that the peculiarities of old-style classes are not
well documented today, more generally than just this tidbit, alas.
Alex
More information about the Python-list
mailing list