can I query an instance for its name?

Bjorn Pettersen bjorn at roguewave.com
Fri Sep 29 22:54:31 CEST 2000


so if I do:

 x = foo()
 y = x
 y.who()

what should it print?

-- bjorn

Luc Lefebvre wrote:
> 
> Hi,
> 
> <\newbie alert on>
> 
> I have been attempting to get access to instance names, eg:
> 
> class foo:
>         def __init__(self):
>                 pass
> 
>         def who(self):
>                 print "%s is an instance of class %s" % (self.????, self.__class__)
> 
> if __name__=="__main__":
>         x=foo()
>         x.who() # would expect "x is an instance of class foo"
> 
> Also, is there a way to enquire as to a given classes children eg: foo.__children__?
> 
> <\newbie alert off>
> tia
> 
> --
> http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list