def __init__(self, num, den = 1):
        if den == 0:
            raise ZeroDivisionError, 'rat(x, 0)'

        # normalize

        # must check complex before float
        if (isinstance(num, complex) or
            isinstance(den, complex)):
            # numerator or denominator is complex:
            # normalized form has denominator == 1+0j
            self.__num = complex(num) / complex(den)
            self.__den = complex(1)
            return
        if isinstance(num, float) or isinstance(den, float):
            # numerator or denominator is float:
            # normalized form has denominator == 1.0
            self.__num = float(num) / float(den)
            self.__den = 1.0
            return
        if (isinstance(num, self.__class__) or
            isinstance(den, self.__class__)):
            # numerator or denominator is rational
            new = num / den
            if not isinstance(new, self.__class__):
                self.__num = new
                if isinstance(new, complex):
                    self.__den = complex(1)
                else:
                    self.__den = 1.0
            else:
                self.__num = new.__num
                self.__den = new.__den
        else:
            # make sure numerator and denominator don't
            # have common factors
            # this also makes sure that denominator > 0
            g = gcd(num, den)
            self.__num = g / num
            self.__den = den / g
        # try making numerator and denominator of IntType if they fit
        try:
            numi = int(self.__num)
            deni = int(self.__den)
        except (OverflowError, TypeError):
            pass
        else:
            if self.__num == numi and self.__den == deni:
                self.__num = numi
                self.__den = deni
dataset/ETHPy150Open robmoggach/python-moshion/moshion/extractframes/Rat.py/Rat.__init__/swapped operands of `/`