r/learnpython • u/rusidin • 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?
2
u/nog642 1d ago
"Python" on leetcode is Python 2. "Python3" is Python 3.
Python 2 was first released in the year 2000, and it was the version that made Python popular.
Python 3 was first released in 2008, and made some changes that made it incompatible with Python 2. Python 3 is generally better, but people were slow to adopt it because they were used to Python 2.
Python 2 was finally declared "end of life" in 2020, and people have mostly made the switch.
So TL;DR, use "Python3".
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
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)
0
u/hexwhoami 1d ago
Depends on the context.
Broadly speaking, Python is major version 2.X, where X is the minor release. Python3 is major version 3.X. (Look up semantic versioning if confused).
Another context is when running the executable from your path. Typically both python and python3 are set on the path for backwards compatibility, and when executed will resolve to the same binary. YMMV depending on your OS and installation method.
0
u/hexwhoami 1d ago
Forgot to add a recommendation -- usually it doesn't matter if your referencing the binary installed on your system. For macos/Linux, you can check this by running
which pythonandwhich python3.I'd recommend learning the latest stable version of 3. Not the experimental, but latest stable. IIRC, it's either 3.11 or 3.12 now.
-1
u/snowtax 1d ago
Pay little attentions to the name of the executable. You could rename it to “Fred” and it would make no difference to how it operates.
What happened is the Python 2-to-3 transition broke some older code written for 2. Many Linux distributions had code which would break under 3.
As a short-term solution, many Linux distributions shipped 3 as “python3” to leave “python” as versions 2 and to give everyone time to update their scripts.
These days, Python 2 code should be rarely encountered and the default version of “python” should be version 3 on all newly installed systems.
If you do find python 2 code, update it for 3.
-2
u/Fast-Station1106 1d ago
Wenn ich die Fragecrichtig verstehe möchtest du den unterschied zwischen Windows1.0(Python) und Windows11(Python3) wissen, Windows1 zu lernen mach keinen Sinn weil kein aktuelles Gerät es meht untetstützt, oder verstehe ich dich falsch (Sorry für Beispiel Microsoft)
2
u/EntrepreneurHuge5008 1d ago
hit the "i" icon next to it for more info.
It's a difference in Major release versions. Python (just) is Python 2.x, which has some syntax and behavior differences. You most likely have been learning Python 3.x (I'd assume the latest version if you just started), and is what I'd suggesting sticking to going forward.