相关疑难解决方法(0)

为什么我不能用ipython访问Django shell中的导入函数?

我已经在我的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)

python django shell ipython

5
推荐指数
1
解决办法
954
查看次数

标签 统计

django ×1

ipython ×1

python ×1

shell ×1