Last active
May 16, 2022 01:20
-
-
Save rhee/c038393822eabec681092b6941ef1f1e to your computer and use it in GitHub Desktop.
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
""" | |
# https://gist.github.com/rhee/c038393822eabec681092b6941ef1f1e | |
# fake_ipython.py | |
Usage: | |
from fake_ipython import get_ipython | |
""" | |
from inspect import stack | |
def get_ipython(): | |
class ipython: | |
def system(self, str): | |
print('>>> system() ignored:', str) | |
def run_cell_magic(self, magic, rest, content): | |
print('>>> cell_magic() exec:', magic, rest, content) | |
_globals=stack()[1].frame.f_globals | |
exec(content,_globals) | |
def run_line_magic(self, magic, rest): | |
print('>>> line_magic() ignored:', magic, rest) | |
return ipython() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment