[Tutor] How to extract numerator and denominator from fractions.Fraction(4, 32)?
Jim Mooney
cybervigilante at gmail.com
Tue Aug 6 09:16:24 CEST 2013
On 5 August 2013 21:21, eryksun <eryksun at gmail.com> wrote:
> This looks like a job for IterableFraction:
No, it's a job for SpammyFraction ;')
from fractions import Fraction
class SpammyFraction(Fraction):
def spam(self):
return [self.numerator, self.denominator]
>>>SpammyFraction(6, 21).spam()
[2, 7]
Seriously, though, I thought yield was like return - one and you're
done - how are you getting two yields in there?
--
Jim
The Curiosity Rover has been on Mars a year Huh? It feels like it
landed, at most, a few months ago. Where in hell is the time going?
More information about the Tutor
mailing list