Can please someone explain how one may use 'is' in an 'if' condition. I am working with the fractions module, and I'm having some trouble:
>>> Fraction(0, 1) is 0
False
>>> float(Fraction(0, 1))
0.0
>>> float(Fraction(0,1)) is 0.0
False
The only thing I found to work is:
>>> F = Fraction(a,b)
>>> if F >= 0:
... if F(0, 1) <= 0:
... ...
Is there a way to use 'is' here? Thanks.
a is b
is equivalent to id(a) == id(b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With