Re: [Tutor] Change to Class-level Variable

2010-10-03 Thread Alan Gauld
"Robert" wrote class Foo( object ): ... myid = 'Foo' ... def __init__( self ): ...pass ... f1 = Foo() f2 = Foo() f1.myid = 'Bar' This creates a myid instance variable in f1 which hides the class variable. You should always modify class variables via the class not an insta

Re: [Tutor] Change to Class-level Variable

2010-10-03 Thread Steven D'Aprano
On Mon, 4 Oct 2010 09:06:39 am Robert wrote: > Why is "f1" not affected by the Class-level variable change below ? The Python terminology is "attribute", not variable. You have class attributes and instance attributes. > >>> class Foo( object ): > ... myid = 'Foo' > ... def __init__(

[Tutor] Change to Class-level Variable

2010-10-03 Thread Robert
Why is "f1" not affected by the Class-level variable change below ? >>> class Foo( object ): ... myid = 'Foo' ... def __init__( self ): ...pass ... >>> f1 = Foo() >>> f2 = Foo() >>> f1.myid = 'Bar' >>> Foo.myid = 'SPAM' >>> f1.myid <--- Why is "f1" not a