title: How can I use property functions in methods in python?
body: <p>I tried writing Code 2 to do the same thing as Code 1. But, Code 2 did not work. Why? How can I use property functions in methods in python?</p>
  
  <p>(Code 1)</p>
  
  <pre><code>class Spam:
      def __init__(self, is_less_sodium):
          self.__is_less_sodium = is_less_sodium
  
      def __getter(self):
          return self.__is_less_sodium
  
      is_less_sodium = property(__getter)
  
  my_spam = Spam(False)
  print(my_spam.is_less_sodium)
  
  ########## Result ##########
  # False
  </code></pre>
  
  <p>(Code 2)</p>
  
  <pre><code>class Spam:
      def __init__(self, is_less_sodium):
          self.__is_less_sodium = is_less_sodium
          Spam.is_less_sodium = property(self.__getter)
  
      def __getter(self):
          return self.__is_less_sodium
  
  my_spam = Spam(False)
  print(my_spam.is_less_sodium)
  
  ########## Result ##########
  # Traceback (most recent call last):
  #   File "code2.py", line 10, in &lt;module&gt;
  #     print(my_spam.is_less_sodium)
  # TypeError: __getter() takes 1 positional argument but 2 were given
  </code></pre>
  
  <p>I understood that the return value of <code>property(__getter)</code> is assigned to <code>is_less_sodium</code>, which is a class variable of <code>Spam</code>, in Code 1. But, this understanding seems wrong.</p>