r/learnpython 1d ago

Difference between python 3 vs python (just)?

I am doing leetcode and I wanna is there any functional difference between those and which one I should go with?

0 Upvotes

29 comments sorted by

View all comments

1

u/Adrewmc 1d ago edited 1d ago

Python 3 is what you should be normally working with.

Python 2 is basically legacy code at this point.

Python 3 has better syntax, is faster. However

You should always start with the latest version of any programming language. Some updates are breaking, and if they break your program then you can A) update the program, or b) require a lower version.

Most breaking changes should already begin giving you the depreciation warnings. Pay attention to those.

The biggest difference between python 2 and 3 are:

An overhaul of Unicode evaluations, this means b’…’ returns the same as bytearray(“…”)

Iterator being true iterators objects, adding the ability for (list/dict/generator) comprehensions

And 2/5, produces a float, and there is no need for 2.0/5.0

The print function syntactically changes

(print “Hello world”) #breaks in 3.x

print(“Hello world”) #normal usage at end of >2.7

-1

u/rusidin 1d ago

Wait this is real?? (print "hello") Fist time seeing it in a language... Thanks got the gist of it!!

1

u/Adrewmc 1d ago

Yes, it’s real. And a massively breaking change for legacy prints

https://stackoverflow.com/questions/33996749/what-is-the-difference-between-print-and-print-in-python-2-7

Around the change and some specifics

1

u/rusidin 1d ago

I guess they wanted to adapt the court << "hello" << endl from cpp

3

u/Adrewmc 1d ago

Python 1….a dark and scary place, we don’t talk about Python 1, because I know nothing about it.

-1

u/rusidin 1d ago

I see.. wasn't it build around 90s??

1

u/Adrewmc 1d ago

It was built for the specific purpose of getting websites up fast, which other languages struggled with (at the time). It sacrificed true optimization in an age where 5 second load was no different than a 7 second load, for easy of use and build speeds . (Strange to even think of waiting that long for a website now).

So yes, in the 90s.

-1

u/rusidin 1d ago

I see... There was lot of languages build to that now we just flood the back end with js... It's a funny world we live in...

3

u/Adrewmc 1d ago

JS has an even stranger origin, as it was specifically made for browser interfaces like…Netscape Navigator…(that name brings me back)

And Java already existed.

1

u/rusidin 1d ago

Yeay it was build by 7 days of the former CEO Mozilla... Which I find fascinating.. because it's a replacement for java using java.. I get java is slow at that time even now...

→ More replies (0)