[Tutor] How to extract numerator and denominator from fractions.Fraction(4, 32)?

Alan Gauld alan.gauld at btinternet.com
Mon Aug 5 19:18:13 CEST 2013


On 05/08/13 16:49, Amit Saha wrote:
>>
>> Ah, better yet! Thanks! But where could I have found that in
>> <http://docs.python.org/3/library/fractions.html#module-fractions>?
>
> Sometimes, you may also want to do dir() on an object to see what
> attributes/methods it has/supports.

Also
 >>> help(fractions.Fraction)

yields lots of details including the following:

...
  |  ----------------------------------------------------------------------
  |  Data descriptors defined here:
  |
  |  denominator
  |
  |  numerator
  |



HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list