I'm doing something similar to the following
class Parrot(object):
def __init__(self):
self.__voltage = 100000
@property
def voltage(self):
"""Get the current voltage."""
return self.__voltage
However it sees the voltage property as an int so when I call like so
p = Parrot()
print(p.voltage())
I get
TypeError: 'int' object is not callable
I've tried with one and two underscored to mangle the voltage property name.
The whole point of the getter is that it returns the value without being called. p.voltage returns the integer object, so running p.voltage() is equivalent to 100() or something.
There can still be cases where you want to call the value of a property, like if the value is itself a function. But you don't need it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With