mholub
mholub3mo ago

private imports inside one cell

I tried to do such code
import subprocess as _subprocess
import os as _os

def open_symbol_location(symbol):
location = get_symbol_location(symbol)
_subprocess.Popen(
["code", location],
preexec_fn=_os.setsid,
stdout=_subprocess.DEVNULL,
stderr=_subprocess.DEVNULL
)
import subprocess as _subprocess
import os as _os

def open_symbol_location(symbol):
location = get_symbol_location(symbol)
_subprocess.Popen(
["code", location],
preexec_fn=_os.setsid,
stdout=_subprocess.DEVNULL,
stderr=_subprocess.DEVNULL
)
i.e. basically import modules as private variables just for a single cell when I am using such function in another cell - I am getting error Obviously it's not a big deal but could be useful situationally but I don't know if it's a bug or more like explicitly unsupported thing?
No description
2 Replies
Akshay
Akshay3mo ago
I think that's a bug. Even this doesn't work. Looks like there's an edge case related to imports we don't handle
No description
Akshay
Akshay3mo ago
Put up a fix. Thanks for reporting!