Learning Python 2.7 after learning Python 3 difficult?

Hi Everyone,

I’m following a really comprehensive python course on udemy
Python- Deep Dive 1/2/3

The teacher is very thorough but it is in python 3, and I will be using that for the duration of the course.

Will switching back to 2.711 for Maya scripitng be a huge issue? In terms of relearning stuff?

(After the course, and some other training I have a bunch of modeling tools to write)

It seems like they are fairly close but there are a few things to watch out for? I have Learning Python 5th addition as a reference book to check differences.

I just can’t seem to find as in-depth a course as the Python - Deep Dive on Udemy for Python 2.711.

What do you think?

Depending on the version of 3 you’re learning with it will definitely depend.
But 2.7 is largely at a feature parity with 3.4, as a feature lock was in place up until 3.5. yield from and raise from being the major syntax differences. However if you’re used to things like f-strings or async / await, then you’ll be out of luck.

The other stuff would be slightly different layouts to the standard library, though much of that was backported.

And of course the infamous str / bytes / unicode backwards compatibility break.

I would however recommend using a library like six or futurize , these allow you to write code in a compatible manner across multiple versions of python.

1 Like

Hey R.White

The Course is in Python 3.6. I’m pretty much a beginner, so I can’t even tell the difference. Not sure if it’s better to go with a less deep course or just suck it up and deal with differences later on.

I’m usually testing segments of code in Maya anyway so maybe it’ll be okay.

I would stick with it as 97+% of the knowledge will transfer over pretty cleanly.
Especially as we’re getting closer and closer to the end of official support for python2.x more and more folks will be relying on courses like the one you are taking that primarily target the newer python3 versions.

1 Like

whew, thank you so much! that’s what I was hoping to hear… now back to work!!

I personally found this cheat sheet helpful:

https://python-future.org/compatible_idioms.html

The string vs bytes vs unicode issue still trips me up from time to time. Iterating through dictionaries can be different as well.

Good luck!

2 Likes

One other useful thing.
Usually best to include the following at the top of any python2x code.

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
2 Likes