[Tutor] Introspecting class and method names

Brian van den Broek broek at cc.umanitoba.ca
Thu Dec 15 02:04:27 CET 2005


Tim Johnson said unto the world upon 2005-12-14 18:02:
> I was pleasantly surprised to notice in a previous thread that python
> can automagically retrieve a class name thru __class__.__name__
> 1)Can someone point me to further documentation on this topic?
> 2)Is it possible for the name of a class method to be 
>   programmatically retrieved from within the scope of the method?
>   If so, how? and pointers to docs would be welcome also.
> 
> thanks

Hi Tim,

I'm glad that other got use out of Kent's answers to my questions :-) 
(Thanks again Kent.)

For points related to (2), you might want to check out the inspect 
module, Tim. I don't immediately see a way to accomplish (2), but I've 
not looked closely. However, if these points interest you, much of 
inspect will be of likely interest, too.

Best,

Brian vdB



More information about the Tutor mailing list