Skip to content

Instantly share code, notes, and snippets.

@anfedorov
Created October 18, 2016 17:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anfedorov/e355feed3321ff954d2b3ab4849a71e5 to your computer and use it in GitHub Desktop.
ipython embed issues
fluffy:code fedorov$ ipython
Python 2.7.12 (default, Oct 11 2016, 05:24:00)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: x = 1
In [2]: (lambda: x)()
Out[2]: 1
In [3]: def f():
...: return x
...:
In [4]: f()
Out[4]: 1
In [5]:
Do you really want to exit ([y]/n)?
fluffy:code fedorov$ python
Python 2.7.12 (default, Oct 11 2016, 05:24:00)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import IPython
>>> IPython.embed()
Python 2.7.12 (default, Oct 11 2016, 05:24:00)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: x = 1
In [2]: (lambda: x)()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-06e79b397fa8> in <module>()
----> 1 (lambda: x)()
<ipython-input-2-06e79b397fa8> in <lambda>()
----> 1 (lambda: x)()
NameError: global name 'x' is not defined
In [3]: def f():
...: return x
...:
In [4]: f()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-0ec059b9bfe1> in <module>()
----> 1 f()
<ipython-input-3-058183df4e0e> in f()
1 def f():
----> 2 return x
NameError: global name 'x' is not defined
In [5]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment