Skip to content

Instantly share code, notes, and snippets.

@quandyfactory
quandyfactory / hasmethods.py
Created February 4, 2010 15:53 — forked from vlazzle/hasmethods.py
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
)
#!/usr/bin/env python
from Tkinter import *
from random import shuffle
things = [
'Make some tea',
'Do some pushups',
'Do some situps',
'Go to the bathroom',