|
|
|
|
|
by masklinn
5031 days ago
|
|
> Not the one you replied to, but one thing that hits me as awkward is the default static behavior of variables. There's no default anything, what you wrote sets "bar = 1" on the class itself, nothing more an nothing less, just as if you'd written: Foo = type("Foo", (object,), {'bar': 1})
(in fact that's pretty much what the class statement is sugar for)If you want to set it on the instance, set it on the instance. Python's class context is a namespace like every other, you can do any computation you wish in there, and at the end the ``class`` statements collects all bindings of the namespace and sets them on the class. |
|