Earlier quoted context omitted.
Yes, I'd say Python's crown as the go-to lightweight scripting and web development language was mostly ceded to JS. It's still reigning champion of data science, and of course it has a huge number of uses and users still around, but it's not really cool or in vogue outside of those circles.
Do people really turn to JS (instead of Python) for lightweight scripting? Are we talking about the "better Bash" use case?
I'm switching to Python and actually liking it
671–680 of 718 posts
Re: I'm switching to Python and actually liking it
#672I really don't find the Python language elegant at all. I prefer the Ruby syntax. But Python's tooling, particularly with what Astral is doing (uv, ruff, ty), is so good, I'm always using Python and virtually never using Ruby. And yeah, the rich libraries, too.
Re: I'm switching to Python and actually liking it
#673Earlier quoted context omitted.
Assertions are disabled via `python -O` so they probably shouldn't be used like this.
On the other hand, presumably the program will just crash anyway with some terse permission/request error later on if these values aren't set
Re: I'm switching to Python and actually liking it
#674Earlier quoted context omitted.
Neophytes take notice. Attention to details like this is what separates truly great programmers from merely good ones. That said, for scripts reusable by others you should use command line arguments . Environment variables in lieu of command line arguments is a huge code smell.
Typer has a great feature that lets you optionally accept argument and flag values from environment variables by providing the environment variable name: https://typer.tiangolo.com/tutorial/arguments/envvar/ It's especially nice for secrets. Best of both worlds :)
One could write a huge treatise on everything that is wrong with environment variables. Avoid them like the plague. They are a huge usability PITA.
Re: I'm switching to Python and actually liking it
#675Earlier quoted context omitted.
I have a bunch of zero dependency projects. You can get a lot done with the standard library and single file projects which you can run on most systems without needing to do anything except curl it down and run it since Python is available. For example here's a ~2k line Python project which is a command line finance income and expense tracker: https://github.com/nickjj/plutus/blob/main/src/plutus It uses about a doze…
Argparse is part of my problem with Python! I can never remember the weird ways it wants to collect all these attributes and features, so I'm always leafing through manual pages or googling for examples. Same for if I'm modifying existing Argparse code, I have no idea how to make it do what I want. It can do a lot for you, but it's a pain in the ass to use. It's so much easier to write a simple usage() function that…
One nice thing about argparse is it comes with a helper function for mutually exclusive groups that can be optional or required. For example you can have --hello OR --world but not both together.
Re: I'm switching to Python and actually liking it
#676Earlier quoted context omitted.
Then how would you SET the API key in the first place? :) The argument doesn't make any sense at all.
In some .profile or .envrc or what you'd call such a file, I suppose.
Re: I'm switching to Python and actually liking it
#677Earlier quoted context omitted.
Python's success is entirely due to entry-level programming courses. They all switched to Python, because you have to explain less. I don't think I heard about web servers in Python before 2012. I suppose a 2005 computer wouldn't be able to serve a Python backend smoothly. PHP's popularity isn't really from 2005-2006. It was popular at the end of the 90s, and it looks like JS as much as it looks like a potato.
1. Python was pretty popular well before entry-level programming courses adopted it. I think they adopted Python because it was a good general purpose scripting language, multiplatform, easy to install and get going, that taught programming concepts in a more approachable way for beginners. 2. Python on web servers was a thing long before 2012. You had Zope in 1998 or so, and it was pretty popular for a while, and hu…
Re: I'm switching to Python and actually liking it
#678Earlier quoted context omitted.
> making it harder for yourself Looking at just the first link, looks way more complicated than venv. And I'm a C++ developer, imagine someone who less experienced, or even who just isn't familiar with C toolchains.
The first link is a sudo apt install command that you copy paste into terminal. in what world is that more complicated than venv? Here it is for clarity sudo apt-get install build-essential gdb lcov pkg-config \ libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \ libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \ lzma lzma-dev tk-dev uuid-dev zlib1g-dev libmpdec-dev libzstd-dev
It's the kinda thing an experienced engineer wouldn't have that much trouble with, but you should be able to recognize how much experiential knowledge is required to compile a complex C code base and what kinda dumb stuff can go wrong.
You probably don't need to do much of the stuff on that page to build, but "What is dnf?", "Is the pre-commit hook important?", "Do I need cpython?", "What's an ABI dump?" are questions many people will the wrestling with while reading.
Re: I'm switching to Python and actually liking it
#679Earlier quoted context omitted.
Millions of people put it into Docker, or they just deal with it and you see the results with tons of Stackoverflow questions
> Millions of people put it into Docker, or they just deal with it and you see the results with tons of Stackoverflow questions Arrogantly wrong. I've coded in Python for almost 20 years. Many of those years I've had it as my primary language at work. 2024 was the first year I actually needed a virtualenv. Before that, I'd happily use pip to install whatever I want, and never had a version conflict that caused proble…
Okay I'll bite: how did you deal with situations where you needed to work on two different projects that required different versions of the same dependency?
Re: I'm switching to Python and actually liking it
#680Earlier quoted context omitted.
I'll pay attention to poetry soon. As is, I don't recall my builds ever going slow because of poetry. I don't think I've noticed it have any impact on speed, at all. I did just update the dependencies of some of my projects. I could see how that could be faster. I don't do that often enough for me to care about it, though. `poetry run pytest` is the slowest thing I have, and I'm confident most of that slowness is in…
uv supports the standardised lock file format. This means that you're not tied to uv for anything, as most project settings it uses (eg metadata, dependencies, extras, etc.) are based on PEPs. poetry has its own format for many things. https://peps.python.org/pep-0751/