Re: Introspection Class/Instance Name

2006-04-26 Thread robert
*binarystar* wrote: > Hello there, > > what method would you use to return the name of the class and/or > instance introspectively eg. > > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_ret

Re: Introspection Class/Instance Name

2006-04-26 Thread Duncan Booth
*binarystar* wrote: > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_returns_instance_name__() > > > instance_of_bollocks = Bollocks() > > # Which outputs > > 'Bollocks' > 'i

Re: Introspection Class/Instance Name

2006-04-26 Thread [EMAIL PROTECTED]
What about: py> class A: py. def __init__(self): py. print self.__class__.__name__ py. print str(self) py. def __str__(self): py. return 'instance of %s' % self.__class__.__name__ py. py> a = A() A instance of A py> -- http://mail.python.org/mailman/l

Re: Introspection Class/Instance Name

2006-04-25 Thread Roland Heiber
*binarystar* wrote: > Hello there, > > what method would you use to return the name of the class and/or > instance introspectively eg. > > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_ret

Introspection Class/Instance Name

2006-04-25 Thread *binarystar*
Hello there, what method would you use to return the name of the class and/or instance introspectively eg. class Bollocks: def __init__( self ): print self.__method_that_returns_class_name__() print self.__method_that_returns_inst