Skip to content

Instantly share code, notes, and snippets.

@ghost-ng
Last active March 21, 2017 19:26
Show Gist options
  • Save ghost-ng/c3560b785166be0f23e11fcb9438a249 to your computer and use it in GitHub Desktop.
Save ghost-ng/c3560b785166be0f23e11fcb9438a249 to your computer and use it in GitHub Desktop.
pyWebConsole.py
from code import InteractiveConsole
class Console(InteractiveConsole):
def __init__(*args): InteractiveConsole.__init__(*args)
def enter(self, source):
source = self.preprocess(source)
self.runcode(source)
@staticmethod
def preprocess(source): return source
console = Console()
console.preprocess = lambda source: source[4:]
console.enter('>>> print(1)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment