P
Paul LaFollette
Kind people,
Using Python 3.1
I have been poking around trying to get more insight into Python's
innards, and I have a couple of (marginally) related questions.
First, I've looked a fair bit and can't find how one can find the base
classes of a subclass? isinstance and issubclass sort of do the
opposite of what I want. Surely somewhere there is something like
MyThingee.something.orOther.baseClasses()
that returns a tuple of the parents? If there is, can you point me to
the appropriate documentation?
Second,
I can subclass most builtin things like int and float and list and so
on, and then override operators to play Twilight Zone if I am so
inclined.
But what happens if I try to subclass function?
First attempt:.... pass
....
Traceback (most recent call last):
OK.. so second attempt:
.... pass
....Traceback (most recent call last):
.... pass
....
Traceback (most recent call last):
So, it appears that function is perhaps the equivalent of a Java final
class? Or isn't really a class at all but something that "looks like"
a class?
Anyway, again can you point me to somewhere that I can learn more? In
particular, is there a list somewhere of the builtin types that are
not subclassable?
I'm willing to root through the source code if that is what I need to
do, but even there (especially there) a hint as to where to start
looking would be helpful.
Thank you in advance,
Paul
Using Python 3.1
I have been poking around trying to get more insight into Python's
innards, and I have a couple of (marginally) related questions.
First, I've looked a fair bit and can't find how one can find the base
classes of a subclass? isinstance and issubclass sort of do the
opposite of what I want. Surely somewhere there is something like
MyThingee.something.orOther.baseClasses()
that returns a tuple of the parents? If there is, can you point me to
the appropriate documentation?
Second,
I can subclass most builtin things like int and float and list and so
on, and then override operators to play Twilight Zone if I am so
inclined.
But what happens if I try to subclass function?
First attempt:.... pass
....
Traceback (most recent call last):
OK.. so second attempt:
.... pass
....Traceback (most recent call last):
.... pass
....
Traceback (most recent call last):
So, it appears that function is perhaps the equivalent of a Java final
class? Or isn't really a class at all but something that "looks like"
a class?
Anyway, again can you point me to somewhere that I can learn more? In
particular, is there a list somewhere of the builtin types that are
not subclassable?
I'm willing to root through the source code if that is what I need to
do, but even there (especially there) a hint as to where to start
looking would be helpful.
Thank you in advance,
Paul