implementing negation by overriding __neg__ in python
<p>I am learning classes right now and I attempted to make a program which operates on Fractions.
I am posting some extract from the code:</p>

<pre><code>class Fraction():
    def __init__(self,numerator,denominator=1):
        g = gcd(numerator,denominator)
        self.numerator = numerator / g
        self.denominator = denominator / g

    def __add__(self,other):
        if isinstance(other,int):
            other = Fraction(other)
        return Fraction((self.numerator * other.denominator + self.denominator * other.numerator),(self.denominator * other.denominator))

    def __neg__(self):
        return (-self.numerator , self.denominator)

    def __sub__(self,other):
        other = other.__neg__()
        return self + (-other)

    def __mul__(self , other):
        if isinstance(other,int):
            other = Fraction(other)
        return Fraction(self.numerator*other.numerator,self.denominator*other.denominator)

    __rmul__ = __mul__

    def printit(self):
        print '(' + str(self.numerator) + '/' + str(self.denominator) + ')'

def gcd(m,n):
    if(m%n == 0):
        return n
    else:
        return gcd(n,m%n)

#Input is of the form

    Fraction.printit(Fraction(5,6) + Fraction(1,6))
    Fraction.printit(Fraction(5,6) - Fraction(1,6))
</code></pre>

<p>Previous Indentation error has been taken care of. It was a sort of malfunctioning when I copied my code from this page to notepad++. Indenting again solved the problem.
Now the error which is arising is this:</p>

<pre><code>(1/1)     #This is the first answer, works perfectly. 

Traceback (most recent call last):
File "Fractions.py", line 36, in &lt;module&gt;
    Fraction.printit(Fraction(5,6) - Fraction(1,6))
File "Fractions.py", line 15, in __sub__
    return (self + (-other))
TypeError: bad operand type for unary -: 'tuple'    
</code></pre>