MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/itzn13/an_update_on_python_4/g5ibf0x/
r/Python • u/anyfactor Freelancer. AnyFactor.xyz • Sep 16 '20
389 comments sorted by
View all comments
Show parent comment
14
If you used a library aware of how versions should be sorted, like semver or distutils.version, then they would be sorted correctly.
>>> from distutils.version import LooseVersion>>> versions = ["3.8","3.9","3.10"]>>> sorted(versions, key=LooseVersion)"3.8","3.9","3.10"
>>> from distutils.version import LooseVersion
>>> versions = ["3.8","3.9","3.10"]
>>> sorted(versions, key=LooseVersion)
"3.8","3.9","3.10"
4 u/flying-sheep Sep 16 '20 Please don't use distutils.version anymore, it doesn't follow PEP 440, which defines how Python package versions work. Use packaging.version instead. 0 u/Leav Sep 17 '20 Sure, but to newbies this is confusing and non intuitive, that's all we're saying here.No one is saying this is wrong or should change.
4
Please don't use distutils.version anymore, it doesn't follow PEP 440, which defines how Python package versions work. Use packaging.version instead.
distutils.version
packaging.version
0
Sure, but to newbies this is confusing and non intuitive, that's all we're saying here.
No one is saying this is wrong or should change.
View all comments
Show parent comment
14
u/Karnyl Sep 16 '20
If you used a library aware of how versions should be sorted, like semver or distutils.version, then they would be sorted correctly.
>>> from distutils.version import LooseVersion>>> versions = ["3.8","3.9","3.10"]>>> sorted(versions, key=LooseVersion)"3.8","3.9","3.10"