小编mkn*_*cht的帖子

Django-reversion和南兼容性

django-reversion是否适用于南迁?
django-reversion和南方兼容吗?

当前版本:
- 回归 - 1.2.1
- 南 - 0.7.1

django compatibility django-models django-south django-reversion

10
推荐指数
1
解决办法
1964
查看次数

让IPython导入我的意思

我想默认修改IPython如何处理导入错误.当我在IPython shell中对原型进行原型化时,我通常会忘记首先导入os,re或者我需要的任何内容.前几个陈述经常遵循这种模式:

In [1]: os.path.exists("~/myfile.txt")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-0ffb6014a804> in <module>()
----> 1 os.path.exists("~/myfile.txt")

NameError: name 'os' is not defined

In [2]: import os

In [3]: os.path.exists("~/myfile.txt")
Out[3]: False
Run Code Online (Sandbox Code Playgroud)

当然,这是我的错,因为有坏习惯,当然,在一个有意义的脚本或真正的程序中,但在shell中我宁愿IPython遵循DWIM原则,至少尝试导入我想要使用的东西.

In [1]: os.path.exists("~/myfile.txt")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-0ffb6014a804> in <module>()
----> 1 os.path.exists("~/myfile.txt")

NameError: name 'os' is not defined

Catching this for you and trying to import "os" … success!
Retrying …
---------------------------------------------------------------------------
Out[1]: False
Run Code Online (Sandbox Code Playgroud)

如果使用vanilla IPython无法做到这一点,我需要做些什么来使其工作?是 …

python ipython ipython-magic

6
推荐指数
1
解决办法
376
查看次数