On Mon, 30 Apr 2001 00:22:53 GMT, timothyr at timothyr.com (Timothy L. Robertson) wrote: >Hi Everyone, > >I've been enjoying learning Python very much, but have hit a little >snag. I want a way to find out the name of a class instance from a >method. eg. > >>>>classinstance=MyClass() >>>>classinstance.myname() >'classinstance' > >Is there a way to do this? If you want it to have a name, you're going to have to give it one yourself... class MyClass: def __init__(self, myname): self.myname = myname >>>classinstance=MyClass('classinstance') >>>classinstance.myname() >>>'classinstance' Daniel Klein Portland, OR USA
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4