Class attributes newbie question (before I join a cargocult)

Christoph Haas email at christoph-haas.de
Sun Mar 12 19:51:06 CET 2006


Am Sonntag, 12. März 2006 19:36 schrieb EP:
> This is likely a stupid question, but I am confused about what is going
> on with class attributes as far as whether they "stick".  I ran across
> this in a program I am writing, but have reproduced the behavoir below
> - can someone point me in the right direction (thanks):
>
> class AttStickiness(object):
>     def __init__(self, myname="", mysex=""):
>         self.name=myname
>         self.sex=mysex

               ^--- sex

>     def changeSex(self, newsex=""):
>         self.mysex=newsex

               ^--- mysex

You are not altering the same attribute.

Cheers
 Christoph
-- 
~
~
".signature" [Modified] 1 line --100%--                1,48         All



More information about the Python-list mailing list