Created
October 27, 2010 20:00
-
-
Save sergray/649833 to your computer and use it in GitHub Desktop.
proposed antigravity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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