class_docstr: This class implements rational numbers.
  
  In the two-argument form of the constructor, Fraction(8, 6) will
  produce a rational number equivalent to 4/3. Both arguments must
  be Rational. The numerator defaults to 0 and the denominator
  defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
  
  Fractions can also be constructed from:
  
    - numeric strings similar to those accepted by the
      float constructor (for example, '-2.3' or '1e10')
  
    - strings of the form '123/456'
  
    - float and Decimal instances
  
    - other Rational instances (including integers)
class_docstr_tok: ["This","class","implements","rational","numbers",".","In","the","two-argument","form","of","the","constructor",",","Fraction","(","8",",","6",")","will","produce","a","rational","number","equivalent","to","4\/3",".","Both","arguments","must","be","Rational",".","The","numerator","defaults","to","0","and","the","denominator","defaults","to","1","so","that","Fraction","(","3",")","==","3","and","Fraction","(",")","==","0",".","Fractions","can","also","be","constructed","from",":","-","numeric","strings","similar","to","those","accepted","by","the","float","constructor","(","for","example",",","'-2.3","'","or","'1e10","'",")","-","strings","of","the","form","'123\/456'","-","float","and","Decimal","instances","-","other","Rational","instances","(","including","integers",")"]
docstr: Converts a finite float to a rational number, exactly.
  
  Beware that Fraction.from_float(0.3) != Fraction(3, 10).
docstr_tok: ["Converts","a","finite","float","to","a","rational","number",",","exactly",".","Beware","that","Fraction.from_float","(","0.3",")","!","=","Fraction","(","3",",","10",")","."]
code: def from_float(cls, f):
      """Converts a finite float to a rational number, exactly.
  
      Beware that Fraction.from_float(0.3) != Fraction(3, 10).
  
      """
      if isinstance(f, numbers.Integral):
          return cls(f)
      elif not isinstance(f, float):
          raise TypeError(
              "%s.from_float() only takes floats, not %r (%s)"
              % (cls.__name__, f, type(f).__name__)
          )
      return cls(*f.as_integer_ratio())
  
imports: from decimal import Decimal
  import math
  import numbers
  import operator
  import re
  import sys
label_desc: Use image node_id 2 for calling the Fraction obj's underlying member method code with example usage: obj.from_float(cls, f) and returns: cls, cls