3 ms·
Being 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 pa
by sph 4y ago
Being 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.
- XorNot 4y agoSo by way of example - suppose I have this: # some other code if determined_value := some_function_call(): do_action(determined_value) and then I change it to this: # some other code determined_value = some_function_call() logger.info("Determined value was %s", determined_value) validate(determined_value) if determined_value: do_action(determined_value) and determined_value is a reasonably expensive operation (at the very least I would never want to redundantly do it twice) - then in this case my diff for this looks like: --- <unnamed> +++ <unnamed> @@ -1,5 +1,8 @@ - # some other code -if determined_value := some_function_call(): +determined_value = some_function_call() +logger.info("Determined value was %s", determined_value) +validate(determined_value) + +if determined_value: do_action(determined_value) whereas if I wrote it without walrus originally: --- <unnamed> +++ <unnamed> @@ -1,5 +1,8 @@ # some other code determined_value = some_function_call() +logger.info("Determined value was %s", determined_value) +validate(determined_value) + if determined_value: do_action(determined_value) then the diff is easier to read, and the intent is clearer because diff can simply infer that what's happening is the semantic addition of two lines. Code is read more then it's written, and changed more then originally created, and making the change case clearer makes sense.
- tmh88j 4y agoYour issue is with the readability of the diff? That is so trivial. You're trying to find anything to complain about at this point. How about just look at the code? You should be doing that anyway.
- ok_dad 4y agoIt’s really handy in comprehensions to do assignments outside the normal syntax.
- thayne 4y agoAn example where I have wanted this many times before it existed is in something like: while (n := s.read(buffer)) != 0: #do something with first n bytes of buffer Without the walrus operator you either have to duplicate the read operation before the loop and at the end of the loop, or use while True with a break if n is zero. Both of which are ugly IMO.
- takeda 4y agoBut Python has a decent and a reproducible way of installing packages. The problem python has is that things evolved over time, so you can find on the net plenty of outdated information. There is also a lot of blogs and articles with bad practices, most written by people that got something working. I think also a lot of issues with packaging is ironically because of PyPA that supposed to work on a standard, but in reality instead of embracing and promoting something that works they just pushes half-assed solutions because author is one of the members. Kind of like they were pushing failed Pipenv "for humans". Seems like Poetry is generally popular and devs are happy with it, so of course PyPA started pushing their own Hatch project, because python packaging was finally getting too straight forward. I think Python would benefit as a whole if PyPA was just dissolved.
- leetrout 4y ago> I think Python would benefit as a whole if PyPA was just dissolved STRONG agree. And I hate the cult of personality that was previously (still?) strong.
- oarabbus_ 4y ago>But Python has a decent and a reproducible way of installing packages. Reading the comment thread it's not immediately clear what the answer is - it seems implied that the proper way is using Poetry, is that the case?
- Ygg2 4y agoIt's not. See https://imgs.xkcd.com/comics/python_environment_2x.png https://imgs.xkcd.com/comics/python_environment_2x.png Or sometime the computer is haunted and my colleague had problems installing tensorflow. To this day he has no working tensorflow.
- takeda 4y agoI suppose we can follow memes or facts. Please note I never used tensorflow on that computer in fact I never used tensorflow, but this is my experience: https://gist.github.com/takeda/89ec29501b6e8641415668f22f3e99b7 https://gist.github.com/takeda/89ec29501b6e8641415668f22f3e9... It succeeded after first try. I do see that in their repo[1] they use a non standard way to build the package. They use Bazel, but that's Google for you. They never do things everyone else is doing. I'm not sure why this is Python problem rather than package problem. They have tons of open issues around building: [2] [1] https://github.com/tensorflow/tensorflow https://github.com/tensorflow/tensorflow [2] https://github.com/tensorflow/tensorflow/labels/type%3Abuild%2Finstall https://github.com/tensorflow/tensorflow/labels/type%3Abuild...
- rewgs 4y agoI used to think this and rage at the current state of Python dependency management. Then I just buckled down and learned the various tools. It's honestly fine.
- hota_mazi 4y agoYup. Java is 27 years and has a splendid package management system (Maven Central) which is so well designed that you can use it from two different tools that are extremely different (Maven and Gradle).