Skip to content

Instantly share code, notes, and snippets.

@mkuhn
Created August 19, 2010 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkuhn/537895 to your computer and use it in GitHub Desktop.
Save mkuhn/537895 to your computer and use it in GitHub Desktop.
# with the help of decorators, keep track of the functions
# we would like to use for fitting
fit_functions = []
def fit_func(f):
fit_functions.append(f)
return f
class C(object):
def __init__(self):
...
@fit_func
def fit1(self):
"""This is the first function"""
...
@fit_func
def fit2(self):
"""This is the second function"""
...
## This function is disabled by putting the decorator in a comment
# @fit_func
def fit3(self):
"""This is the third function"""
...
def main():
c = C()
for f in fit_functions:
fit = f(c)
print fit, f.__doc__
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment