Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

541–550 of 718 posts

Re: I'm switching to Python and actually liking it

#541
post #80

Just a small note on the code in the linked script: API_KEY = os.environ.get("YOUTUBE_API_KEY") CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID") if not API_KEY or not CHANNEL_ID: print("Missing YOUTUBE_API_KEY or YOUTUBE_CHANNEL_ID.") exit(1) Presenting the user with "Missing X OR Y" when there's no reason that OR has to be there massively frustrates the user for the near zero benefit of having one fewer if statemen…

Or

  API_KEY = os.environ.get("YOUTUBE_API_KEY")
  CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID")

  assert(API_KEY, "Missing YOUTUBE_API_KEY")
  assert(CHANNEL_ID, "Missing CHANNEL_ID")

Re: I'm switching to Python and actually liking it

#542
post #65

Python has done an impressive job over the years of making steady robust improvements. The typing and tooling has just gotten better and better. There are still plenty of problems though, imho async is still a much bigger pain than it should be (compared to other runtimes with a very nice experience like go or elixir, even dotnet has been less pain in my experience). Overall I like python, but it mainly boils down to…

I don't know what I am doing wrong but nothing written in Python has ever worked for me. I download the .py repo from from github or wherever and try to run it - errors. I try to install missing libraries pip this and that - errors. I battle fixing endless error with dependencies and when the .py finally runs - errors - wrong version of whatever library or wrong patch of this or that or the "production ready" .py doe…

My own experience could hardly be more different. For that matter, I have never had to even look at a "flashy looking web site and follow all the instructions to the letter" in order to install something.

For example, to install yt-dlp, I followed these steps:

  sudo apt install pipx
  pipx install yt-dlp
Actually, only the second one, because I already had pipx (https://pipx.pypa.io/ — a wrapper for pip that does basic virtual environment management) installed.

Can you name some specific things in Python you have tried to use, and give more concrete descriptions of how you tried to set them up?

Re: I'm switching to Python and actually liking it

#543
post #522

> So yeah, Python is powerful, and it couples very well with the now ubiquitous VSCode editor. I always found vscode lacking for Python and C compared to pycharm and clion. The latter just work without fiddling with config files.

Funny enough I feel the other way about JetBrains IDEs. They * seem * super powerful, but there is always a lot of config that needs to go into them if I'm doing app, infra, and pipeline work. (Edit, not saying they aren't powerful, just more that as coming into them I'm never sure how to wield it the best out of the box)

In my experience (not saying this is universal), the folks that like JetBrains IDEs came from java/intellij backgrounds, where I hear it really shines.

This all might be a skill issue, as almost all my professional projects have been VSCode based, but since I've only worked at smaller places I definitely can't rule out this was because it was easier to set things up than to fight for Fin to get us all licences.

In your opinion, what makes PyCharm (or CLion if you want to add that in) 'just work'? Do you think it is because you've used it for so long and just know the ins-and-outs? Or is there something you see that they have and VSCode doesn't?

I've always been curious about this as someone who hasn't had a lot of professional exposure to the JetBrains world.

Re: I'm switching to Python and actually liking it

#544

Earlier quoted context omitted.

The reason that people still code in Java (or derivative) is because legacy code that they are working on is in Java, and nobody has either the skill or time to go through and translate it. Which means that the jobs where its used are basically just big enterprise, low tech software that just been around for a while. The Log4shell incident is the perfect demonstrator of what kind of people are in Java world.

> nobody has either the skill or time to go through and translate it. To what? Java is still a very efficient, productive language. Updating a legacy codebase to use newer Java features would probably be good, but migrating to another language is unlikely to significantly move the needle in terms of runtime performance or developer velocity.

Most of the use cases for java are in places where network latency dominates. If Python is fast enough for Uber and Youtube, its fast enough for your service.

When you work with a codebase that doesn't need compilation, the development velocity is quite fast. You don't need to compile, you can prototype features on the fly, you can even write real time updates while the web server is running.

And standard compilation in Java is done in a VERY inefficient manner with groovy - you have groovy that gets compiled to bytecode, which then gets JIT compiled to native, which then actually runs the compilation of the source code to bytecode, and then you have a first startup latency as it gets JIT compiled to native.

All you really need to write any modern app is Python + C. Anything that needs to go fast, just encapsulate in a small C program, and launch that from Python.

Re: I'm switching to Python and actually liking it

#545
post #38
post #2

> the Python interpreter is natively integrated in all Unix distros It's included in the default install of most desktop/server Linux distros (with plenty of exceptions), but I don't believe any of the BSDs ship it in their base system. IIRC macOS used to have python 2 in its default install, but I vaguely recall that being deprecated and removed at some point. My only Mac is on the other side of the country at the m…

Python 2 was removed in Monterey 12.3, which was incredibly stupid and disruptive as it caught everyone by surprise. We all knew Apple said they would remove it, but everyone was expecting them to be sensible and do it on a new major OS release, like they did with PHP, not mid-cycle. https://developer.apple.com/documentation/macos-release-note... I wonder if that kerfuffle is why they ended up not removing Ruby and P…

> [Software that was officially EOL and no longer supported by the developer as of January 1, 2020 — even though they went back on that with an emergency patch in April] was removed in [an OS released on October 25, 2021], which was incredibly stupid and disruptive as it caught everyone by surprise [despite the fact that the intent to EOL that software was declared many years ahead of time, and that sunset date already represented an extension of multiple years to the usual release schedule].

I will never understand this.

But then, I've been using Python 3 since 3.2 and my first reaction to that was a sigh of relief, and by the time I updated to 3.4 I was already wondering why everyone else was lagging behind on the switch.

Re: I'm switching to Python and actually liking it

#546
If you use Make as a task runner like in the article, please make sure that you're also declaring your tasks as .PHONY targets: https://www.gnu.org/software/make/manual/html_node/Phony-Tar...

Otherwise, the existence of a file or folder with the same name as your task ("test", for example) will stop that task from being run, which might be very annoying if you're using the Makefile as part of a script or CI or something where you won't notice the "Nothing to be done for..." message.

Re: I'm switching to Python and actually liking it

#547
post #11

Earlier quoted context omitted.

Python's package management is OK. The main culprit is .so libraries Think JNI or cgo management.

I'll throw in BLAS and LAPACK. Fuck, what a nightmare it always has been to get scipy running. I've always ended up with a wild mix of conda and pip installed shit that just wouldn't work.

Really? `pip install scipy` in a new environment just works for me. What concrete issues are you encountering?

Re: I'm switching to Python and actually liking it

#548

So, i don't get it, now i still need to have a uv venv ?

There's only one kind of Python virtual environment, and both uv and the standard library `venv` module make them (as does third-party support like `virtualenv`). The differences are in what gets put in them (aside from the actual packages you explicitly install), and in the interface for configuring that. In particular, the standard library defaults to bootstrapping pip, but you can easily skip that. And of course uv does not bootstrap pip, because it does pip's job (and much more).

Re: I'm switching to Python and actually liking it

#549
post #429

Earlier quoted context omitted.

You don't generally want API keys accidentally recorded into someone's bash history.

What exactly is your threat model, where the attacker can read ~/.bash_history but can't execute (or capture output from) /usr/bin/env?

You do NOT save passwords in shell history, it is insanely insecure. Lets begin with the passwords being readable by everything that can list tasks.

You can protect passwords in a password manager. You do not need to keep the passwords in env and I do not.

Re: I'm switching to Python and actually liking it

#550

Earlier quoted context omitted.

What exactly is your threat model, where the attacker can read ~/.bash_history but can't execute (or capture output from) /usr/bin/env?

You do NOT save passwords in shell history, it is insanely insecure. Lets begin with the passwords being readable by everything that can list tasks. You can protect passwords in a password manager. You do not need to keep the passwords in env and I do not.

> Lets begin with the passwords being readable by everything that can list tasks.

Why are processes running that can do this, that I don't already fully trust?

> You can protect passwords in a password manager.

What's your plan for supplying the password to the program, given that people will want to automate use of the program?

Post reply on HN