Fraction Class in Python
The from_string() function is missing a @staticmethod decorator, and thus does not work in Python 2.



Your greatest_common_divisor() function works using brute force: it literally tests every possible divisor and picks the greatest one that is common to both.  A much faster method is the Euclidean Algorithm.

@staticmethod
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a




Validation and error handling could be tightened up a bit.  


The rejection of floating-point arguments is inconsistent:


&gt;&gt;&gt; Fraction(3.14, 1)
3.14/1
&gt;&gt;&gt; Fraction.from_string('3.14/1')
Traceback (most recent call last):
  […]
  File "fraction.py", line 55, in &lt;listcomp&gt;
    return Fraction(*[int(i) for i in text.split('/')])
ValueError: invalid literal for int() with base 10: '3.14'


Instantiating a Fraction with strings initially appears to work, but fails in an odd way later.  Either both of these statements should work, or both should fail.


&gt;&gt;&gt; Fraction('1', '3')
1/3
&gt;&gt;&gt; Fraction('1', '3') + Fraction('2', '3')
Traceback (most recent call last):
  […]
  File "fraction.py", line 32, in div
    return [i for i in range(1,n+1) if n % i == 0]
TypeError: Can't convert 'int' object to str implicitly


In Fraction.from_string(), the abstraction is slightly leaky.  I would prefer to see a ValueError instead of the following:


&gt;&gt;&gt; Fraction.from_string('1/3/5')
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "fraction.py", line 55, in from_string
    return Fraction(*[int(i) for i in text.split('/')])
TypeError: __init__() takes 3 positional arguments but 4 were given


Personally, I would choose to raise a ZeroDivisionError if the denominator is 0.


&gt;&gt;&gt; Fraction(1, 0)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "fraction.py", line 13, in __init__
    raise ValueError("Denominator must not be zero.")
ValueError: Denominator must not be zero.