+ 2

what is the diffrence between python and python3.

what changes we will have to make in the code made for python2.X to run on python 3.X interperator. can we import the libraries of python 2.X to python3.X Sorry , if this is a stupid question because i am new to the programing world

15th Mar 2017, 6:40 AM
Rahul Pal
Rahul Pal - avatar
3 Respostas
+ 4
Hi Rahul, A similar question was just asked recently today, I dug up a link I seemed to use a few times ages ago which may help you: http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html If you are just starting out, start with python3! if you have a particular question related to it post it here and we can help out :)
15th Mar 2017, 6:47 AM
Elric Hindy
Elric Hindy - avatar
+ 2
I see you updated your question :) yes you can import most libraries, however some do not have the same syntax. I use configparser in some of my code which had to be compatible with many versions so I do a check against the python version with: if (sys.version_info > (3, 0)): from configpaser import * else: from ConfigParser import * note the case on the python 3 is all lower case. also using python 3 you should use unicode strings where possible as newer modules only work with those, however python 2 does work with the same. another one I recently came across was StringIO for compatibility i used: import StringIO #for python2 and import io as StringIO # for python3 that's just some examples.
15th Mar 2017, 7:06 AM
Elric Hindy
Elric Hindy - avatar
+ 1
thanx , link is the guide of differences :)
15th Mar 2017, 6:53 AM
Rahul Pal
Rahul Pal - avatar