Skip to content

Instantly share code, notes, and snippets.

@quandyfactory
Forked from vlazzle/hasmethods.py
Created February 4, 2010 15:53
Show Gist options
  • Save quandyfactory/294784 to your computer and use it in GitHub Desktop.
Save quandyfactory/294784 to your computer and use it in GitHub Desktop.
hasmethods function.
# if there are any others who don't care much for try ... catch AttributeError
def hasmethods(obj, *meth_names):
return all(
hasattr(
# if it calls like a method it's a method
getattr(obj, m, None),
'__call__'
) for m in meth_names
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment