I am doing something like this:
class Class(object): def __init__(self): self.var=
How do I get the __ init __ method of my instance to use the instance name string for 'c'? Let's say in the case of:
c=Class()
I want c.var to be equal to 'c'.
Thanks for your answers, I use persistence, and Class is a constant class of objects. I want __ init __ to add a record to the database when:
c=Class()
Then suppose:
del c
Later:
c=Class()
sholuld create an instance using the data from the database if there is already an 'c' entry, otherwise create a new entry.
Thanks for your answers, I use persistence, and Class is a constant class of objects. I want __ init __ to add a record to the database when:
c=Class()
Then suppose:
del c
Later:
c=Class()
sholuld create an instance using the data from the database if there is already an 'c' entry, otherwise create a new entry.
source share