|
|
|
|
|
by DeepDuh
5031 days ago
|
|
Well in my case foo = Foo(); print foo.bar will print 1, so it does 'kinda' work as a default value. And that's ok, I just remembered there to be some case where it didn't behave the way I expected it to (e.g. instance member assignment overriding the content of another instance), but I wasn't able to reproduce it right now. |
|
Of course it will, Python's attribute-resolution (as do most languages) tries the instance, then the class, then the superclass, then... why wouldn't it work?
> I just remembered there to be some case where it didn't behave the way I expected it to (e.g. instance member assignment overriding the content of another instance)
Only two way I see for that to happen:
1. Re-setting the member on the class itself, not the instance
2. Or having the member be mutable and mutating it, since it's set on the class it's shared by all instances.