Skip to content

Instantly share code, notes, and snippets.

@sergray
Created October 27, 2010 20:00
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 sergray/649833 to your computer and use it in GitHub Desktop.
Save sergray/649833 to your computer and use it in GitHub Desktop.
proposed antigravity
__doc__ = "Add fly function to namespace where module is imported"
class RealWorldLevitation(Exception):
pass
def expose(obj):
import inspect
frame = inspect.currentframe()
frame.f_back.f_back.f_globals[obj.__name__] = obj
return obj
@expose
def fly():
raise RealWorldLevitation('possible in http://xkcd.com/353/')
# so the usage of module is as simple as
>>> import antigravity
>>> fly()
# and there's some Python magic inside
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment