我已经在我的virtualenv中安装了ipython,所以python manage.py shell给我的ipython.但是,我无法从函数定义内部访问导入:
$ python manage.py shell
Python 2.7.5 (default, Sep 6 2013, 09:55:21)
Type "copyright", "credits" or "license" for more information.
IPython 1.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]: from re import search
In [2]: def my_search(pattern, string):
return search(pattern, string)
...:
In [3]: my_search('x', 'y')
---------------------------------------------------------------------------
NameError …Run Code Online (Sandbox Code Playgroud)