Hacker News new | ask | show | jobs
by asdfaoeu 3278 days ago
I feel like most of these complicated if else statements can generally be written much better for example.

    SUPERTYPES = {'Real': ['Integer'],
                  'Complex': ['Real'],
                  'Integer': []}
            
    def is_subtype(a, b):
        if a == b:
            return True
        return any(is_subtype(x, b) for x in SUPERTYPES[a])
Which better expresses the intention of the code and is more flexible.