Programming in Python

2

I downloaded python 3.4 on the site, but some commands do not work in this version compared to python2.7 does it make any difference? In the python2.7 manual, and can I install two?

    
asked by anonymous 15.05.2015 / 21:42

2 answers

3

If you are right at the beginning, the biggest difference you will find in relation to the documentation for Python 2 is the "print" command - it ceases to be a command and becomes a function - So in Python 3, always use print as a function call, with parentheses:

print ("Alô mundo!") 

Of course there are many other changes - many only visible to more advanced users. Internally, the biggest change is that strings in Python 3 contain text characters, whereas in Python 2.x they always contained "bytes". The bytes and text characters match for numbers, some symbols, and uncharted letters - but for other characters besides these, you need to specify a coding.

Even so, at the basic learning level, Python will "guess" the text encoding of your operating system and things will work.

Here's a cool video lesson on the biggest differences between versions: link

And here's a post with a lot of stuff: link

One thing that is important to understand is that the two versions are still retained - why many existing projects already in Python 2 were not ported to Python 3. But nowadays, it is certainly better to learn version 3.4

p>     
15.05.2015 / 22:17
2
  • Yes, there are several differences between versions.
  • Yes, you can install the two versions of python (2.x and 3.x) on the same machine.
  • To know which version to use: link

    To see the differences in more detail: link

        
    17.05.2015 / 08:08