Python 3.4 versus 2.7

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
maxand
Space Floater
Posts: 36
Joined: Tue Mar 18, 2008 5:42 am
Location: Australia

Python 3.4 versus 2.7

#1 Post by maxand »

I'm planning to put some time into learning Python and notice FO uses v2.7, whereas the latest stable version is 3.4.

Should I start writing scripts in 3.4 then modify them where necessary so they will run in 2.7, or should I keep two separate IDEs, one for each version? I haven't studied all the differences between the two versions, and wonder why all the scripts used in FO haven't been updated to 3.4 by now. Is this really as big an issue as it appears to me?

I'd prefer to learn using just one version (preferably the latest) and stick with it. Thanks for your suggestions.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Python 3.4 versus 2.7

#2 Post by Geoff the Medio »

maxand wrote:...why all the scripts used in FO haven't been updated to 3.4...
Because:
-Boost.Python previously didn't support Python 3 (even if it does now), so Python 2 was used for FreeOrion
-FreeOrion Scripting works fine with Python 2.7 and there's no pressing need to update that I'm aware of
-Python 2 is (I vaguely gather) more widely supported / available by default than Python 3
-Updating would be a bunch of (unnecessary) work to repackage everything in the SDKs and (probably) rewrite scripts
-There are / were problems with Python running within FreeOrion already, and I don't want to mess with it more than necessary

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Python 3.4 versus 2.7

#3 Post by Vezzra »

That pretty much sums it up...

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Python 3.4 versus 2.7

#4 Post by Cjkjvfnby »

maxand wrote:I'm planning to put some time into learning Python and notice FO uses v2.7, whereas the latest stable version is 3.4.

Should I start writing scripts in 3.4 then modify them where necessary so they will run in 2.7, or should I keep two separate IDEs, one for each version? I haven't studied all the differences between the two versions, and wonder why all the scripts used in FO haven't been updated to 3.4 by now. Is this really as big an issue as it appears to me?

I'd prefer to learn using just one version (preferably the latest) and stick with it. Thanks for your suggestions.
There is not big difference between coding with 2.7 and 3.4 (2.7 has a lot of backported features from 3). 3.4 has a lot of cool features but most of them can be implemented in 2.7. If you write 2.7 code in clear and simple way it can be easily ported to python3.

PS. Best IDE for python PyCharm.
PS. Make quick look at checkio.org there is possible to see solutions of other peoples, it helps a lot.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Python 3.4 versus 2.7

#5 Post by Dilvish »

Cjkjvfnby wrote:If you write 2.7 code in clear and simple way it can be easily ported to python3.
This is the focus I think we should have for now, 2.7 code that will be easily portable to 3.

For Linux reference points: the Debian stance is apparently to ship both 2.7 and the latest stable 3 for the foreseeable future (with 2.7 the current default). Ubuntu (derived from Debian) is apparently being used to spearhead a transition to python 3
Move Python 2 to universe, port all Python applications in main to Python 3. We will never fully get rid of Python 2.7, but...All Ubuntu/Canonical driven development should be targeting Python 3 right now, and all new code should be Python 3-only.
Also note:
What this does not mean:
/usr/bin/python will point to Python 3. No, this is not going to happen (unless PEP 394 advocates otherwise, which is doubtful for the foreseeable future). /usr/bin/python and /usr/bin/python2 will point to Python 2.7 and /usr/bin/python3 will point to the latest supported Python 3 version.
Python 2 will be removed from the archive. No, this is not going to happen. We expect Python 2.7 to remain supported and available in Ubuntu for quite a long time
The Windows/ Mac OSX plans are less clear to me, but appear to be similar.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Python 3.4 versus 2.7

#6 Post by MatGB »

Windows doesn't come with Python, for quite a long time I DLd this game every so often to see the progress saying "this'll be an awesome game when there's an AI that does something", and then someone noticed and put a version of python in the windows install files...

So yeah, I suspect the default will be there are no plans to support by default, because, well, Windows. No clue about Mac. It makes sense to me to stick with whatever Ubuntu are recommending as the default, because that's the only Linux version that hasn't made me want to give up and wipe the harddrive immediately...
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply