[Tutor] Variable Modification in a class

Rick Pasotto rick@niof.net
Tue Jun 3 11:47:01 2003


On Tue, Jun 03, 2003 at 05:32:34PM +0200, Mehta, Anish wrote:
> 
> Where does the difference lie between this code and its equivalent 
> python code. Where i am going wrong in my python code for this type of 
> code in C
> 
> Waiting for reply
> 
> Thanks for responding
> 
> Regards
> 
> Tom Jenkins wrote:
> 
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >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

This defines two alternate names for the class 'ab'. It does not create
instances of the class. To do that you would need to do:

	b = ab()
	c = ab()

-- 
"For the same reason, the collective force cannot be legitimately
 employed to foster the love of labor, sobriety, thrift,
 generosity, learning, religious faith; but it can be legitimately
 employed to further the rule of justice, to defend every man's
 rights." -- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rick@niof.net    http://www.niof.net