Spyder executes from __future__ import division
in its console.
This is discussed at https://code.google.com/p/spyderlib/issues/detail?id=1646 - it looks like this will be deactivated by default to avoid confusion.
Vra
I have encountered a quite weird case in Python.
In Spyder:
>>> 274/365
0.7506849315068493
>>> sys.version
'2.7.6 (default, Dec 20 2013, 14:08:04) [MSC v.1700 64 bit (AMD64)]'
>>>
However in command line it returns 0.
>>> 274/365
0
>>> 274/365 * 1.0
0.0
>>> 274/365.0
0.7506849315068493
Same version of Python.
Could anyone tell what is wrong here? Do I need to put some other options ahead of the program? This is really nauseous since my code gave weird results if I call it through command line..
Oplossing
Spyder executes from __future__ import division
in its console.
This is discussed at https://code.google.com/p/spyderlib/issues/detail?id=1646 - it looks like this will be deactivated by default to avoid confusion.
Ander wenke
You either use different versions of Python (in Spyder 3.* and on command line 2.*) or in your Spyder there is automatic import for your console including
from __future__ import division
On command line for Python 2.7
>>> 4/3
1
>>> from __future__ import division
>>> 4/3
1.3333333333333333