(num)
A helper for converting numbers
        to Fraction only when possible.
A helper for converting numbers
        to Fraction only when possible.
A helper for converting numbers to Fraction only when possible .
def _rationalize_if_possible(num):
        '''
        A helper for converting numbers
        to Fraction only when possible.
        '''
        if isinstance(num, Rational):
            res = Fraction(num, 1)
            return Fraction(res.numerator, res.denominator)
        else:
            return num
def _rationalize_if_possible ( num ) : if isinstance ( num , Rational ) : res = Fraction ( num , 1 ) return Fraction ( res . numerator , res . denominator ) else : return num