r/Python • Freelancer. AnyFactor.xyz • Sep 16 '20

News An update on Python 4

Post image
3.3k Upvotes

389 comments sorted by

View all comments

Show parent comments

8

u/Jethro_Tell Sep 16 '20

Why?

-3

u/Leav Sep 16 '20

Because 3.10 = "3.1 with more precision" to engineers and scientists and basically all non-developer users.

How would python sort these lists: [3.8,3.9,3.10] or ["3.8","3.9","3.10"]?

2

u/flying-sheep Sep 16 '20

None of these lists contain versions. Try this one:

from packaging.version import Version

versions = [Version(v) for v in ["3.8", "3.9", "3.10"]]
assert sorted(versions) == versions

For versions containing only numbers (and not e.g. 3.9b1) you can also think of them as tuples of integers.

0

u/Leav Sep 17 '20

Yes, I understand this is how versions work, but to someone who is not familiar with them, it looks extremely weird and confusing.

→ More replies (1)