Python property returning property object

后端 未结 4 1827
别跟我提以往
别跟我提以往 2021-02-19 02:57

I have a class like this:

class Foo(object):
    def __init__(self):
        self.bar = property(self.get_bar)

    def get_bar(self):
        return \"bar\"

pr         


        
4条回答
  •  一生所求
    2021-02-19 03:29

    The object is not instantiated.

    class Foo(object):
      def get_bar(self):
        return "bar"
    
    bar = Foo()
    print(bar.get_bar)
    

提交回复
热议问题