Skip to content

Comment on How many lines of Java would this take?parent

Comments

It's actually the same length in Python. Just take out the extra line breaks from the gist:

    def hasmethods(obj, *meth_names):
        return all(hasattr(getattr(obj, m, None), '__call__') for m in meth_names)

Technically it's one line without semicolons in Python

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.