I am trying to use a property setter as below. I'm following the example here: How does the @property decorator work?
class Contact:
def __init__(self):
self._funds = 0.00
@property
def funds(self):
return self._funds
@funds.setter
def funds(self, value):
self._funds = value
The getter works fine
>>> contact = Contact()
>>> contact.funds
0.0
but I'm missing something about the setter:
>>> contact.funds(1000.21)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1315, in __run
compileflags, 1) in test.globs
File "<doctest __main__.Contact[2]>", line 1, in <module>
contact.funds(1000.21)
TypeError: 'str' object is not callable
What am I doing wrong here?