Tuesday, July 24, 2012

Python: Pass a method as a parameter


def method1():
    return 'hello world'


def method2(methodToRun):
    result = methodToRun()
    return result


method2(method1)


Reference:
http://stackoverflow.com/questions/706721/how-do-i-pass-a-method-as-a-parameter-in-python

No comments: