which version of python ..2 or 3

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
luxatwork
Posts: 9
Joined: Wed Feb 20, 2013 8:46 pm

Re: which version of python ..2 or 3

Post by luxatwork »

jmaustpc wrote:Wouldn't someone, somewhere, would have written some sort of code to help with the conversion of Python between versions?
Yes, but .. since I am newbie I did not know :D
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: which version of python ..2 or 3

Post by yorik »

Basically there is almost only one big difference: print "something" must become print ("something")...
luxatwork
Posts: 9
Joined: Wed Feb 20, 2013 8:46 pm

Re: which version of python ..2 or 3

Post by luxatwork »

yorikvanhavre wrote:Basically there is almost only one big difference: print "something" must become print ("something")...
yes, and anyway I found the book

"How to Think Like a Computer Scientist"

"Python 3.0 Most of the book works for Python 2.x and 3.0. Where there are differences, they are pointed out in footnotes."
simply.. and focuses more on the concept of programming in general.
aj5robinson
Posts: 40
Joined: Sat Apr 28, 2012 10:41 am
Location: Melbourne, Australia

Re: which version of python ..2 or 3

Post by aj5robinson »

Hi All,

I guess you got to this conclusion already but here is the state of affairs regarding Python and C++ in the CAM module:

With the exception of the Post-processor the usage of Python falls into 2 categories: Native Python code (i.e. PyTPG's) OR simply presenting the C++ API's to Python. The PyTPG's only real difference could be with any external modules they make use of. The C++ --> Python presentation is fairly simple so I imagine very few changes being required to move to Python3 and even if there are changes it is very simple code.

The UI is 100% C++ code.

Post processor: some of the more advanced Tool-path functions make use of external libraries that may have some trouble being converted to Python3 however the basic set of Tool-path functions are native Python so shouldn't require much if any change.

As for which language to learn, I would say there isn't much difference but you are probably better off installing Python2.7 if you are developing just to avoid issues with the current code-base. Most the the development will be either native python or C++; most of the code between them is already written (or requires only copy/paste a few more times).

Cheers
Andrew
Post Reply