Programming in Python

Asked

Viewed 157 times

2

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

  • From 2.X to 3.X there have been many changes yes. You can find a description of them here (in English), or if you have doubt with any specific command suggest [Edit] the question with more details. And it is possible to install two versions side by side yes (up to more than two), only you will have to choose at most one to be the "standard Python" (which goes pro PATH, can be called without passing the full path of the executable).

  • The latest version of python 2.7 was released in 2014, to 3 in 2015

  • The 3 has been around longer, the two lines have continued side by side for a long time. As far as I know, now 2.7 only gets security updates and bug fixes, while 3 keeps evolving.

2 answers

3


If you are right at the beginning, the biggest difference you will find regarding the documentation for Python 2 is from 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, while in Python 2.x they always contain "bytes". The bytes and text characters match for the numbers, some symbols, and letters not accented - but for other characters besides these, you need to specify an encoding.

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

Here’s a cool video lesson talking about the biggest differences between versions: http://pycursos.com/python-2-vs-3/

And here a post with enough stuff: https://pythonhelp.wordpress.com/2013/09/01/o-que-mudou-no-python-3/

One thing that is important to understand is that the two versions continue to be maintained - because many existing Python 2 projects have not been ported to Python 3. But today, without a doubt, it is better to learn version 3.4

  • I already program in C.

  • It won’t change much - the biggest differences are really for those who were already programming in Python2.x. I think it’s worth mentioning that the desktop app module has changed from Tkinter (capital T) to tkinter. Now of course worth Voce catch docuemtnação for Python3 to follow.

2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.