title: How to use static/helper method in a class?
body: <p>I'm writting a <code>Fraction</code> class and I am trying to use <code>gcd(a,b)</code> in the initialization of a <code>Fraction</code> object. However, when I was trying to do this it would not work WITHOUT the <code>Fraction</code> part of <code>Fraction.gcd(a,b)</code>. I used <code>@staticmethod</code> here, but it does absolutely nothing, i.e. my code works the same without it. </p>
  
  <p>Is there anyway I can call <code>gcd</code> without putting <code>Fraction.</code> in front of it? In Java I would normally create a static method and then just call it. I could very easily put the GCD code inside of the init, but I am trying to learn here!</p>
  
  <p>I am missing a lot here. Can anyone explain: static methods, helper methods in a class and pretty much how I can use various methods inside of a class?</p>
  
  <pre><code>class Fraction(object):
      def __init__(self, a, b):
          if Fraction.gcd(a, b) &gt; 1:
              d = Fraction.gcd(a, b)
              self.num = a/d
              self.denom = b/d
          else:
              self.num = a
              self.denom = b
  
      @staticmethod    
      def gcd(a,b): 
          if a &gt; b: a,b = b,a
          while True:
              if b % a == 0: return a
              a, b = b%a, a
  
      def __repr__(self):
          return str(self.num) + "/" + str(self.denom)
  </code></pre>