Created
December 26, 2019 08:44
-
-
Save roman-smirnov/a9d2432594c3364c17fd7d980e354f4f to your computer and use it in GitHub Desktop.
Limit code scope to current cell in Jupyter Notebook
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
from IPython.core.magic import register_cell_magic | |
@register_cell_magic | |
def cellscope(line, cell): exec(cell) | |
## Example (in a code cell): | |
# %%cellscope | |
# x = 'hello' # x is local to current code cell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment