fue*_*zig 3 python inheritance class static-variables
我喜欢这样的
class A:
__a = 0
def __init__(self):
A.__a = A.__a + 1
def a(self):
return A.__a
class B(A):
def __init__(self):
# how can I access / modify A.__a here?
A.__a = A.__a + 1 # does not work
def a(self):
return A.__a
Run Code Online (Sandbox Code Playgroud)
我可以访问__a
类变量B
吗?这可能是写作a
而不是__a
,这是唯一的方法吗?(我猜答案可能很短:是的:)