5 ms·
Keep in mind that Python is 31 year old (it's even older than Java) it was created around the same time as world wide web. So it started when no one even knew t
by takeda 4y ago
Keep in mind that Python is 31 year old (it's even older than Java) it was created around the same time as world wide web. So it started when no one even knew they would need dependency management and evolved over time from people posting packages on their home pages, to a central website to what we now call PyPI. Similarly the tooling and way of packaging the code evolved.
What you described are multiple tools that also target different areas:
> - poetry
from what you listed this seems like the only tool that actually takes care of dependency management
> - "Just pin the dependencies and use Docker"
this is standard fallback for all languages when people are lazy and don't want to figure out how to handle the dependencies
> - pip freeze
all this does it just lists currently installed packages in a form that can be automatically read by pip
> - Vendoring in dependency code
this again is just a way that applies to all languages, and it is still necessary even if there's a robust dependency management as there are some cases where bundling everything together is preferred
> - pipreqs
this is just a tool that scans your code and tells you what dependencies you are using. You are really lost if you need a tool to tell you what packages is your application is using, but I suppose it can be useful for one offs if you inherit some python code that wasn't using any dependence management.
> - virtualenv
this is just a method to have dependencies installed locally in project directory instead per system. This was created especially for development (although it can be used for deployment as well) as people started working on multiple services with different dependencies. It's now included in python so it's more like a feature of the language.
- sph 4y agoBeing 31 years old doesn't preclude having a decent, official and reproducible way of installing packages in 2022. That's just a bad excuse to justify subpar package managers and terrible governance around this problem. Package management is pretty much a solved problem, no matter how old is your language. It smells to an outsider like me like a lot of bike-shedding and not enough pragmatism is going on in Python land over this issue. Has a new BDFL stepped up after Guido left?
- FridgeSeal 4y agoNo but there’s a walrus operator! Not sure anyone was asking for that, unlike a fix for packaging issues.
- tmh88j 4y agoI really like the walrus operator. It's helped me to create more straightforward if/elif blocks and loops. Effective python has some pretty good examples. https://effectivepython.com/2020/02/02/prevent-repetition-with-assignment-expressions https://effectivepython.com/2020/02/02/prevent-repetition-wi...
- XorNot 4y agoThis really isn't a good argument though: it's an extra, extremely specific use case for assignment that looks visually very similar. And worse, effects code maintainability - if you need that assignment higher up, you're now editing the if statement, adding an assignment, plus whatever your interstitial code is. Python doesn't have block scoping so the argument for it is weak.
- tmh88j 4y agoIt's not for extremely specific use-case, unless you consider using variables as a condition of an if statement or loop extremely specific. > And worse, effects code maintainability - if you need that assignment higher up, you're now editing the if statement, adding an assignment, plus whatever your interstitial code is. How is that different than variables declared without the walrus operator? If you declare a variable with the walrus operator and decide to move its declaration you can still continue to reference that variable in the same spot, just like any other variable. Do you have an example you can share to demonstrate this? I'm not sure I understand what you mean. > Python doesn't have block scoping so the argument for it is weak. The walrus operator another way to define variables, not change how they behave. It's just another addition to the "pythonic" way of coding. It's helped me to write more concise and even clearer code. I suggest reading the Effective Python link I provided for some examples of how you can benefit from it.
- tmh88j 4y ago> > - pip freeze > all this does it just lists currently installed packages in a form that can be automatically read by pip Are you referring to version specifiers[1] being optional or is there something more to versions that I don't understand? PEP 440 is a wall of text, maybe I should get around to reading it sometime. [1] https://packaging.python.org/en/latest/glossary/#term-Version-Specifier https://packaging.python.org/en/latest/glossary/#term-Versio...
- takeda 4y agoI mean pip freeze outputs packages and their versions in machine readable form that can be read and installed by pip install -r requirements.txt
- tmh88j 4y agoThis whole chain started with someone pointing out the author doesn't seem to realize you can pin versions[1]. I'm just confused how people seemed to end up questioning what pip freeze does. [1] https://news.ycombinator.com/item?id=32141573#32142190 https://news.ycombinator.com/item?id=32141573#32142190
- takeda 4y agoPerhaps I was just proving author's point. I tried to say that from mentioned tools only poetry can be called as a dependency management. The other tools are used for different purposes, but perhaps could be used as a piece of package management in some way. The mentioned docker and vendoring is irrelevant to Python and it even applies to Go.