*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
*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
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
*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
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