title: Python Getters and Setters
body: <h3>How should I access the class instance variables in my <code>roll</code> method?</h3>
  <p>Should I access <code>self._value</code> with <code>self._value</code> or use my setter by accessing with <code>self.value</code>? Same question for <code>self._sides</code>.</p>
  <pre><code>import random
  
  
  class MSDie:
      def __init__(self, sides):
          self._sides = sides
          self._value = 1
  
      @property
      def sides(self):
          return self._sides
  
      @property
      def value(self):
          return self._value
  
      @value.setter
      def value(self, number):
          self._value = number
  
      def roll(self):
          self._value = random.randrange(1, self.sides + 1)
  </code></pre>
  <p>So basically, should I create the <code>roll</code> method like this instead:</p>
  <pre><code>def roll(self):
      self.value = random.randrange(1, self.sides + 1)
  </code></pre>
  <p>Now I know how to do it correctly the conventional way of <code>get_value</code>/<code>set_value</code> but I am trying to learn how to create more pythonic classes.</p>
  <p>Just out of curiosity, why doesn't <code>self.value(random.randrange(1, self.value + 1)</code> or <code>self.value(self, random.randrange(1, self.sides + 1)</code> access the <code>self._value</code> variable and change it?</p>