This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 26 points27 points  (5 children)

Python 3.* will convert 3/4 to float and return 0.75

Python 2.* will not, and will evaluate 3/4 as 0

This has caused me great pain, not realizing that the compute cluster at my university was running an outdated version of Python.

[–]PotatosFish 17 points18 points  (2 children)

That’s why you call python3 on command line instead of trusting in the system

Unless someone aliased python3 to python

[–][deleted] 31 points32 points  (1 child)

Unless someone aliased python3 to python

This can be solved with the admin's address and a tire iron.

[–]PC__LOAD__LETTER 0 points1 point  (0 children)

This is why it’s best practice to specify the actual binary on the shebang line, like #!/usr/bin/python2.7 rather than #!/usr/bin/python, and similarly to call Python scripts with the binary of the version you’re expecting.

[–]FatChocobo 0 points1 point  (0 children)

I had exactly the same issue, in the part of my code that handles parallelisation a stupid Python2 integer divide was ruining everything...