Last active
December 27, 2015 00:49
-
-
Save kurtbrose/7240973 to your computer and use it in GitHub Desktop.
greenlet based REPL -- note dependent on 1.0 gEvent which adds the fileobject module
This file contains hidden or 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
| import sys | |
| import code | |
| from gevent import fileobject | |
| _green_stdin = fileobject.FileObject(sys.stdin) | |
| _green_stdout = fileobject.FileObject(sys.stdout) | |
| def _green_raw_input(prompt): | |
| _green_stdout.write(prompt) | |
| return _green_stdin.readline()[:-1] | |
| def run_console(local=None, prompt="GREEN REPL"): | |
| code.interact(prompt, _green_raw_input, local=local or {}) | |
| if __name__ == "__main__": | |
| run_console() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment