Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
run once decorator
# from
from functools import wraps
def run_once(f):
"""Runs a function (successfully) only once.
The running can be reset by setting the `has_run` attribute to False
def wrapper(*args, **kwargs):
if not wrapper.has_run:
result = f(*args, **kwargs)
wrapper.has_run = True
return result
wrapper.has_run = False
return wrapper
def load_ipython_extension(ip):
"""Load the extension in IPython."""
# do work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.