python的getter/setter
===========================
getsettest.py
===========================
import test
test1 = test.Test()
test1.set__foo = 100
a=0
a = test1.get__foo
print a
test2 = test.Test()
b = test2.get__foo
print b
===========================
test.py
===========================
class Test(object):
def __init__(self):
self.__foo = 0
def get__foo(self):
return self.__foo
def set__foo(self):
self.__foo = foo
===========================
输出
===========================
<bound method Test.get__foo of <test.Test object at 0x00C03A70>>
<bound method Test.get__foo of <test.Test object at 0x00C03A30>>
请教这应该怎么写啊getter/setter...
像java那样写明显不对头啊= =!
[解决办法]
import test
test1 = test.Test()
test1.set__foo() = 100
a=0
a = test1.get__foo()
print a
test2 = test.Test()
b = test2.get__foo()
print b