I'm in the process of setting up a Matlab like environment so I downloaded the latest version of python(x,y) with all the modules that come with it and downloaded python 3.4.1. Does python(x,y) not run the latest version of python? I noticed because the python(x,y) shell doesn't auto calculate mathematical operations into floats which I read is a difference between python 2.x and 3.x. Do I just have to wait for a new release of (x,y) or am I missing something here?
我正在构建一个类似于Matlab的环境,所以我下载了python的最新版本(x,y),并下载了所有的模块,并下载了python 3.4.1。python(x,y)不是运行最新版本的python吗?我注意到,因为python(x,y) shell并没有自动计算数学运算到浮点数,我读到的是python 2的区别。倍和3.倍。我是否需要等待一个新的版本(x,y)或者我遗漏了一些东西?
2 个解决方案
#1
1
You can make Python 2 behave the same as Python 3 w.r.t. division with the following command;
您可以使用以下命令使Python 2的行为与Python 3 w.r.t.分区相同;
from __future__ import division
Imports from __future__
should be the in the top of the file. There is probably a way to auto-load this expression (I know it is possible in IPython) but I'm not familiar with python(x,y).
来自__future__的导入应该位于文件的顶部。可能有一种方法可以自动加载这个表达式(我知道它在IPython中是可能的),但是我不熟悉python(x,y)。
#2
0
For learning more about Python do the tutorials available via python.org. The latest version of Python3 is recommend.
要了解更多关于Python的知识,请使用python.org提供的教程。建议使用最新版本的Python3。
Since you are in a transition process, take a look at SciPy (http://www.scipy.org) and Sage (http://www.sagemath.org/tour.html). These might be a better fit for the problems you need to solve.
由于您处于过渡过程,请查看SciPy (http://www.scipy.org)和Sage (http://www.sagemath.org/tour.html)。这些可能更适合您需要解决的问题。
If you do a lot of interactive work at the terminal, take a look at ipython (http://ipython.org).
如果你在终端做了大量的交互工作,看看ipython (http://ipython.org)。
Regarding the division operator is defaults to integer division in Python2, but will be just normal division in Python3. You can change this by using the -Q flag when starting the interpreter. (Do: python --help) For example:
关于除法运算符是Python2中整数除法的默认值,但它只是Python3中的正常除法。您可以在启动解释器时使用-Q标志来改变这一点。(Do: python—help):
$ python2.7 -Qnew
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>
$ python2.7
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0
>>>
$ python3.4
Python 3.4.1 (default, May 21 2014, 01:39:38)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>
#1
1
You can make Python 2 behave the same as Python 3 w.r.t. division with the following command;
您可以使用以下命令使Python 2的行为与Python 3 w.r.t.分区相同;
from __future__ import division
Imports from __future__
should be the in the top of the file. There is probably a way to auto-load this expression (I know it is possible in IPython) but I'm not familiar with python(x,y).
来自__future__的导入应该位于文件的顶部。可能有一种方法可以自动加载这个表达式(我知道它在IPython中是可能的),但是我不熟悉python(x,y)。
#2
0
For learning more about Python do the tutorials available via python.org. The latest version of Python3 is recommend.
要了解更多关于Python的知识,请使用python.org提供的教程。建议使用最新版本的Python3。
Since you are in a transition process, take a look at SciPy (http://www.scipy.org) and Sage (http://www.sagemath.org/tour.html). These might be a better fit for the problems you need to solve.
由于您处于过渡过程,请查看SciPy (http://www.scipy.org)和Sage (http://www.sagemath.org/tour.html)。这些可能更适合您需要解决的问题。
If you do a lot of interactive work at the terminal, take a look at ipython (http://ipython.org).
如果你在终端做了大量的交互工作,看看ipython (http://ipython.org)。
Regarding the division operator is defaults to integer division in Python2, but will be just normal division in Python3. You can change this by using the -Q flag when starting the interpreter. (Do: python --help) For example:
关于除法运算符是Python2中整数除法的默认值,但它只是Python3中的正常除法。您可以在启动解释器时使用-Q标志来改变这一点。(Do: python—help):
$ python2.7 -Qnew
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>
$ python2.7
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0
>>>
$ python3.4
Python 3.4.1 (default, May 21 2014, 01:39:38)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>