I got this from the fractions
module:
if type(a) is int is type(b):
And as far as I can tell this does the same as:
if type(a) == int == type(b):
But I don't really get how those "chained" is
really work, or what's their use when (imo) ==
looks more readable. Here's the full function
def gcd(a, b):
"""Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
"""
import warnings
warnings.warn('fractions.gcd() is deprecated. Use math.gcd() instead.',
DeprecationWarning, 2)
if type(a) is int is type(b):
if (b or a) < 0:
return -math.gcd(a, b)
return math.gcd(a, b)
return _gcd(a, b)