obj = MyClass() try: func = getattr(obj, "dostuff") func() except AttributeError: print "dostuff not found"