Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

In Python track we should use Python 2x or 3x ?

I have watched already 2-3 videos and the teachers uses Python 3x I think, because of:

print('Hello Python')

Is there big difference between those two version? Which is used more in production?

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

From this article on the key differences between Python 2.x and 3.x:

  • The future module
  • The print function
  • Integer division
  • Unicode
  • xrange
  • Handling exceptions
  • The next() function and .next() method
  • For-loop variables and the global namespace leak
  • Comparing unorderable types
  • Parsing user inputs via input()
  • Returning iterable objects instead of lists

Beyond print, input(), division "/", and steins behave different in Python 3:

A non-exhaustive list of features which are only available in 3.x releases and won't be backported to the 2.x series:

  • strings are Unicode by default
  • clean Unicode/bytes separation
  • exception chaining
  • function annotations
  • syntax for keyword-only arguments
  • extended tuple unpacking
  • non-local variable declarations

This link lists what's new in each Python Release

All of the Treehouse code challenges expect Python 3 code. Workspaces also run Python 3.

It's better to work with Python 3 with Treehouse. After you become well versed in Python 3, learning how to convert to Python 2 and back is not difficult.

Thanks for your great answer!

Zachary Kaufman
Zachary Kaufman
1,463 Points

Python 2 would have print "Hello Python" so only small differences. https://wiki.python.org/moin/Python2orPython3#What_are_the_differences.3F that is the differences between them on the python wiki

Actually, they are pretty different in my opinion. Treehouse uses Python 3, and I mostly use Python 3 too.

Zachary Kaufman
Zachary Kaufman
1,463 Points

I originally learned Python on a website called codecademy and they teach Python 2, I prefer Python 3 also.