I am trying to use both @staticmethod
and @property
on a function bar()
so that the result is returned by Foo.bar
and not Foo.bar()
.
However, Foo.bar
is returning <property object at 0x107e9cb30>
instead of the expected string bar
.
Why is the @property
decorator not working?
def do_work(str):
return str
class Foo:
@property
def foo(self):
return do_work('foo')
@staticmethod
@property
def bar():
return do_work('bar')
f = Foo()
print(f.foo) # foo
print(Foo.bar) # <property object at 0x107e9cb30>
Using Python 3.7.4