-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Milestone
Description
If I have a macro inside a function doesn't work as expected, the same is working fine on __main__
condition. Why?
Define Macro in function throws an error..!
import IPython as ipy
from IPython.terminal.interactiveshell import TerminalInteractiveShell
def run():
shell = TerminalInteractiveShell.instance()
shell.define_macro('foo', """a,b=10,20""")
ipy.embed(display_banner=False)
if __name__ == "__main__":
run()
⋊> ~/c/i/i/ipycli on master ⨯ ipython test
In [1]: foo
Out[1]: IPython.macro.Macro('a,b=10,20\n')
In [2]: a,b
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-2fbdd1b4fa70> in <module>
----> 1 a,b
NameError: name 'a' is not defined
Define Macro in main works fine..!
import IPython as ipy
from IPython.terminal.interactiveshell import TerminalInteractiveShell
if __name__ == "__main__":
shell = TerminalInteractiveShell.instance()
shell.define_macro('foo', """a,b=10,20""")
ipy.embed(display_banner=False)
⋊> ~/c/i/i/ipycli on master ⨯ ipython test
In [1]: foo
In [2]: a,b
Out[2]: (10, 20)
IPython version 7.14.0
OS: macOS Catalina
Terminal: iTerm2 version 3.3.9
Metadata
Metadata
Assignees
Labels
No labels