Question about accessing class-attributes.
Bjorn Pettersen
BPettersen at NAREX.com
Fri May 2 14:16:00 EDT 2003
> From: Michele Simionato [mailto:mis6 at pitt.edu]
>
> "Bjorn Pettersen" <BPettersen at NAREX.com> wrote in message
> news:<mailman.1051832523.2752.python-list at python.org>...
[ class, and instance instantiation...]
> This is also the way I understand how class instantiation works. Maybe
> we are both right (or both wrong ;)
I'm fairly sure the parts I listed are correct from reading the C code.
> > are you saying simply:
> >
> > definition("super class of C with respect to S") ::=
> > S. mro [index(C)+1]
> >
>
> Yes.
Why? What practical benefit would this possibly possess? Let's say I do:
sc = superclass(C,S)
what can I do with sc? Specifically,
sc.a != super(C,S).a
and
sc.a(S, ...) != super(C,S).a(...)
in fact the only thing I can think of that it can be used for is
recreating S.__mro__[index(C)+1:], which is in fact a useful concept
(see super context in the pseudo code I posted).
[pseudocode for super, and attribute lookup semantics...]
> Can you post actual code instead of BNF-like pseudocode, please ?
> I would like to see a real implementation, if possible.
Hmm... Why? (I can't see how implementation details would do anything
but obfuscate the issues)... You're asking me to implement a significant
part of an interpreter, because you don't like to read pseudo-code? Why
don't we try the other way first? You tell me what's unclear, and I'll
clarify.
-- bjorn
More information about the Python-list
mailing list