Classes & Instances

Roman Yakovenko romany at actimize.com
Wed Jan 2 14:42:20 EST 2002


May be this will be helpfull for you
>>> class Obj:
	def Class(self):
		return Obj

	
>>> f = Obj()
>>> f_class = f.Class()
>>> f_class
<class __main__.Obj at 0x0092C7D8>


-----Original Message-----
From: Andrew Nguyen [mailto:pythonnet at hotmail.com]
Sent: Wednesday, January 02, 2002 9:00 PM
To: python-list at python.org
Subject: Classes & Instances


We all know that you can't use classes without instances. 

Now, for the problem. How do I get a class, so that when an instance
is made of it, the class records the instance's name to a list.

e.g, 
class a:
     pass

f = a

----

how do I get f into a list. And remember, my goal is _flexability_ so:

class a:
     pass

f = a

foolist = ['f']

Will NOT work for my goal, but, if let's say there is a function,
'TakeInstanceName()':

class a:
     foolist[:-1]=TakeInstanceName()#This function takes the Instance
name      #  whenever the class is refered to

f = a

#Now after that, foolist should have ['f'], but, my question is, what
IS the #function that would take the TakeInstanceName()'s place?
-----
-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list