Live data from Hacker News

Python Is Eating the World

zdnet.com

61–70 of 993 posts

Re: Python Is Eating the World

#61
post #38
post #14

Earlier quoted context omitted.

Here's a simple but less-than-completely-documented way to keep Python package management under control: 1. Don't install anything globally. Don't pip install --user, definitely don't sudo pip install. 2. For each project you want to work on, create a venv. Yes, there are tools for this, but the base venv tool is totally fine. (venv should be included in your Python, but a few distributors like Debian put it in a sep…

1. pip install --user and sudo pip install are fine actually, they will not interfere with venv, they can co-exist just fine. 2. yes 3. probably do "source bin/activate" first, then run 'pip install -U pip' 4. just run pip install whatever, no need the full PATH 5. just run python directly, no need the full PATH 6. run 'deactivate' when you're done for now, 'source bin/activate' when you want to continue/resume somet…

pip install --user and sudo pip install won't break your venv. But they will break your system Python and any OS commands that depend upon system Python, perhaps including pip and virtualenv themselves, which is incredibly confusing. I've helped both friends and coworkers un-break it, and the symptoms aren't generally obvious. I wrote the patch to pip in Debian to prevent sudo pip install from removing files from Debian packages via upgrading packages. It's a huge pain, it's only worth running if you know exactly what you're doing, and as someone who does know exactly what they're doing I can attest that it's never necessary. After all, you can always just make a virtualenv.

One thing I did at my last job was to make a Nagios alert for machines with files in /usr/local/lib/pythonX.Y/site-packages, indicating that someone had run a sudo pip install, which was super helpful for "why is this machine behaving slightly differently from this other machine which should be identical". We had a supported workflow involving virtualenvs and also we had multiple members of the Debian Python team on staff if you needed systemwide packages, so not only was there always a better solution, there were people to help you with that better solution. :)

Re activate/deactivate, that's a matter of taste but I find it easier to avoid it completely too - see my reply in https://news.ycombinator.com/item?id=20672299 for why. Basically, you get the simple rule of "Never run bare pip" instead of "Remember which pip is your current pip and whether it's the one you meant."

Re: Python Is Eating the World

#63
post #5
post #4

If only its package management were as easy as its syntax... I wish pip worked the same way as npm: -g flag installs it globally, otherwise it creates a local "python_modules" folder I can delete at any time. And optionally I can save the dependency versioning info to some package.json... Instead, pip is a nightmarish experience where it fails half the time and I have no idea where anything is being installed to and…

Use Conda envs!

Conda doesn't really solve the packaging problems of python. It can make them worse if conda doesn't have a package you need.

Re: Python Is Eating the World

#64
post #33

Python has a lot of problems that really slow down development, but they are all fixable. The biggest issue, in my opinion, is in dependency management. Python has a horrible dependency management system, from top-to-bottom. Why do I need to make a "virtual environment" to have separate dependencies, and then source it my shell? Why do I need to manually add version numbers to a file? Why isn't there any builtin way…

The solution to this is Poetry. https://poetry.eustace.io

It's good. Projects should use it.

Re: Python Is Eating the World

#65
post #23

Python and JavaScript Ease of use trumping advanced features every time

I've come back from Ruby as the default scripting language to Python. Over the years, the accumulated Python scripts are much more consistent and easier to read than aged Ruby script. Ease of use, sure. But the language itself I would argue is much better thought-out and consistent. Now, only if it has better type and dependency management ...

Re: Python Is Eating the World

#66
post #4

If only its package management were as easy as its syntax... I wish pip worked the same way as npm: -g flag installs it globally, otherwise it creates a local "python_modules" folder I can delete at any time. And optionally I can save the dependency versioning info to some package.json... Instead, pip is a nightmarish experience where it fails half the time and I have no idea where anything is being installed to and…

Just use Poetry. https://poetry.eustace.io

Re: Python Is Eating the World

#67
In general JavaScript is eating the world.

Python still dominates in numerical computing and JavaScript hasn't been able to make a single dent. Because nobody wants to write

    a.mul(k).add(b)
rather than

    k * a + b
or

    a.set([i,j], b)
rather than

    a[i,j] = b
JavaScript's lack of operator overloading is keeping Python alive.

Python also has integers that feel part of the language, rather than being segregated from normal numbers in case anybody uses integers by accident.

Re: Python Is Eating the World

#68
Remember NOT to jump into Python for your new product if don't know Python. If you are developing for a young startup, have time crunch, then stick to what you know.

IF you do not have a language, or know Python a bit, then pick Python. Here are some of the reasons why I stick to Python (young startup/web APIs):

  - OOPs is not too strict (might give a headache to some folks)
  - Mixins, lambda, decorators, comprehensions - Pythonic ways make me feel productive easily
  - Create a data Model, drop into a shell, import and try things
  - Can do that on a live server
  - Do the same with Controllers, or anything else actually
  - really nothing fancy needed
  - Command line processing, SSH, OS integration, etc. has so many great libs
  - Python Dict someone looks like JSON (this is purely accidental but useful)
  - Debugger support even in free IDE like PyCharm Community Ed is great
  - Integration to a world of services is so easy, even ones you do not commonly see
  - Documentation - many libs have consistent structure and that helps a LOT
  - Really large community, perhaps only smaller than Java
  - The even larger group of people using Python in all sorts of domains from Biotech to OS scripts
What I would like improved in the language would be an even longer list. Every language has a list like that, but when you are focused on being scrappy and building a product, yet making sure that software quality does not take a big hit, Python helps a lot.

Re: Python Is Eating the World

#69
post #55
post #33

Python has a lot of problems that really slow down development, but they are all fixable. The biggest issue, in my opinion, is in dependency management. Python has a horrible dependency management system, from top-to-bottom. Why do I need to make a "virtual environment" to have separate dependencies, and then source it my shell? Why do I need to manually add version numbers to a file? Why isn't there any builtin way…

One thing people overlook with interpreted languages is the environmental impact in terms of extra electricity used.

Gosh yes. These slow languages offload thinking to burning fossil fuels. INEFFICIENT.

Re: Python Is Eating the World

#70
post #42
post #33

Python has a lot of problems that really slow down development, but they are all fixable. The biggest issue, in my opinion, is in dependency management. Python has a horrible dependency management system, from top-to-bottom. Why do I need to make a "virtual environment" to have separate dependencies, and then source it my shell? Why do I need to manually add version numbers to a file? Why isn't there any builtin way…

>Most people just cross their fingers and hope dependencies don't change Is there anything wrong with pip freeze > requirements.txt and then pip install -r requirements.txt ? This would install the exact versions

I've had a good experience with pip-tools (https://github.com/jazzband/pip-tools/) which takes a requirements.in with loosely-pinned dependencies and writes your requirements.txt with the exact versions including transitive dependencies.
Post reply on HN