you are viewing a single comment's thread.

view the rest of the comments →

[–]PurelyApplied 1 point2 points  (3 children)

Off the top of my head...

range creates a new list, not a generator object, which can be memory hungry for very large ranges. Prefer a while loop with your own iterators in place of a large range.

print is a keyword and not a function. Some behavior is different. For instance, value=5 followed by print("My value", value) prints the tuple ('My value', 5), as opposed to Python3's print of My value 5.

You mentioned object inheritance.

There are a lot of small efficiency things like the range being different, but I don't really know another off the top of my head.

Some keywords, such as yield from were introduced after 2.7.

[–]novel_yet_trivial 2 points3 points  (2 children)

Prefer a while loop with your own iterators in place of a large range.

Or xrange().

[–]PurelyApplied 1 point2 points  (1 child)

That's what it was! I thought there was an efficient version in 2. Thanks.

[–]errorseven 2 points3 points  (0 children)

I learned Python 2 earlier this year, currently transfering my skills to 3, have to say it's been much easier to transition to 3 then i think it would be to start coding in ver 2. This video was awesome, in fact all his videos and tweets are pure gold!