Resolving declaring class of a method at runtime
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Thu Nov 15 16:07:58 EST 2007
On Thu, 15 Nov 2007 13:01:27 +0200, Janne Härkönen
wrote:
> Hello,
>
> Is there a simple way to resolve declaring class of a method at runtime
> ?
Have you tried looking at dir(TheClass) to see what it lists?
Also helpful is TheClass.__dict__.keys().
Python has powerful introspection abilities. Learn to use them, and you
too will be able to impress your friends with your Python knowledge.
>>>> class X:
> ... def x(self):
> ... pass
> ...
X is an "old style" class. Most people probably shouldn't use old style
classes, for various reasons. To use new style classes, you inherit from
object:
class X(object)
--
Steven.
More information about the Python-list
mailing list