Question about accessing class-attributes.

Bjorn Pettersen BPettersen at NAREX.com
Wed Apr 30 16:00:47 EDT 2003


> From: Michele Simionato [mailto:mis6 at pitt.edu] 
> 
[..]
> I am sure Alex is going to answer, but since you asked me a related
> question in another thread ...

Sorry, not trying to ignore you, just trying to figure out where the
disconnect was :-)

> Finally, now I see where is the source of the confusion:
> 
> len(S) fails because meta.__len__ is NOT defined in
> you first example. The point is that __getattr__ works on instances of
> meta, NOT on meta itself, therefore S.__len__ is recognized thanks

Well, the whole point of a meta class is that it's "instances" are
regular classes, i.e. the class of a class is called the metaclass...

[meta-meta example...]

> I must say, however, that len(S) is not *literally* 
> type(S).__len__(S):

Yes, that was one of my problems. Where did you find this rule? I can't
find a real reference to it anywhere. For classic classes lookup is
o.__class__.__dict__['attr'].__get__(o.__class__, o) for regular
methods, which sort of looks like the above, but...

[...]
> I did not understood your point in the other thread, I didn't imagine
> you where thinking about meta-metaclasses. As you see, there are 
> situations where they may be useful, i.e. in the customization of 
> metaclasses, but most people don't think at this level yet ;)

I wasn't (or at least wasn't trying to :-). They're facinating beasts
though -- a semantic system with recursion in its axioms ;-)

-- bjorn





More information about the Python-list mailing list