Class properties and object properties
SuperZE
allansuperze at gmail.com
Mon Oct 6 09:38:27 EDT 2008
More information about the Python-list mailing list
Mon Oct 6 09:38:27 EDT 2008
- Previous message (by thread): Class properties and object properties
- Next message (by thread): Class properties and object properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Because you declare myList to be a *class*-level variable, which means *all* > instances of that class (a and b in your case) *share* it. Python does not > declare *instance* variables the way you do. > > Instead, do this: > > class Foo(object): > def __init__(self): > self.myList = [] Interesting, but that does not explain the difference in the behavior of myList and myInt Both were class-level variables, as far as I can see, and therefor a and b should also share it And good remind on default arguments :)
- Previous message (by thread): Class properties and object properties
- Next message (by thread): Class properties and object properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list