"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
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__(
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