Variable Modifications in a class
Bernard Yue
bernie at 3captus.com
Tue Jun 3 14:10:48 EDT 2003
More information about the Python-list mailing list
Tue Jun 3 14:10:48 EDT 2003
- Previous message (by thread): Variable Modifications in a class
- Next message (by thread): Variable Modifications in a class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mehta, Anish wrote: > Hello! > > I am having a problem in tackling the variables in the class. > > class AB: > def __init__(self): > self.a = None > self.b = None > > def func(ab): > b = ab() > c = ab() > > b.a = 5 > b.b = 10 [snip] > > c = b Here is the problem. You set c equal to b! > > c.a = 30 > c.b = 40 > > print b.a, b.b > print c.a, c.b > t = func(AB) > > > Output is > 30 40 > 30 40 > > I want the output to be > 5 10 > 30 40 > > I mean every instance should modify its own set of variables not the > variables of the other instances of the class. The output of the set > of variables of b should not be affected by modifying those variables > by another instance of the same class. > > Waiting for suggestions. > > Thanks in advnace. > > Regards, > > Anish > >
- Previous message (by thread): Variable Modifications in a class
- Next message (by thread): Variable Modifications in a class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list