2 ms·
For modules you can access the variable just fine, but for classes you need to use the mangled name: $ cat >foo.py __FOO = 1 class Foo: __FOO = 2
by Sean1708 7y ago
For modules you can access the variable just fine, but for classes you need to use the mangled name:
$ cat >foo.py
__FOO = 1
class Foo:
__FOO = 2
$ cat >bar.py
import foo
print(foo.__FOO)
print(foo.Foo()._Foo__FOO)
$ python3 bar.py
1
2