Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

331–340 of 718 posts

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

#331

> Not only because the syntax is more human-friendly, but also because the Python interpreter is natively integrated in all Unix distros That's kind of very optimistic evaluation - literally anything beyond "import json" will likely lead you into the abyss of virtual envs. Running something created with say Python 3.13.x on Ubuntu 22.04 or even 24.04 (LTSs) / Rocky 9 and the whole can of worms opened. things like vir…

No and no. I don't know how you even get to this level of "making it harder for yourself". Say you want to use a specific version of python that is not available on Ubuntu. 1. Install build dependencies https://devguide.python.org/getting-started/setup-building/#... 2. Download whichever Python source version you want, https://www.python.org/downloads/source/ . Extract it with tar 3. run ./configure --enable-optimiza…

Personal preference, but I prefer to use 'mise' instead of 'asdf' these days: https://mise.jdx.dev/

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

#332
post #85

Earlier quoted context omitted.

One of my colleagues, a retired programmer who spent 20 years at Microsoft, told my students that it used to be Java vs Visual Basic, until Microsoft brought in the big guns, like Anders Hejlsberg. That's when it turned into Java vs .NET, and things really started to heat up :)

Java unequivocally won the war, though.

C# is the Java of Lua (thanks to Unity) which will never not be weird.

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

#333

> Not only because the syntax is more human-friendly, but also because the Python interpreter is natively integrated in all Unix distros That's kind of very optimistic evaluation - literally anything beyond "import json" will likely lead you into the abyss of virtual envs. Running something created with say Python 3.13.x on Ubuntu 22.04 or even 24.04 (LTSs) / Rocky 9 and the whole can of worms opened. things like vir…

No and no. I don't know how you even get to this level of "making it harder for yourself". Say you want to use a specific version of python that is not available on Ubuntu. 1. Install build dependencies https://devguide.python.org/getting-started/setup-building/#... 2. Download whichever Python source version you want, https://www.python.org/downloads/source/ . Extract it with tar 3. run ./configure --enable-optimiza…

Virtual environments are useful for isolating dependencies for different projects, not just isolating the interpreter.

(I mean, except on Windows, your venvs default to symlinking the interpreter and other shared bits, so you aren't really isolating the interpreter at all, just the dependencies.)

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

#334
post #81

Earlier quoted context omitted.

I'm not sure how "operator+" is supposed to be appreciably different from "__add__".

One is a sensible choice a human might pick. The other is not.

They are both sensible choices that a human did pick, that's how they got into their respective languages.

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

#335

Earlier quoted context omitted.

There are massive numbers of devs who would never even think of trying to code in a dynamically-typed language, even though the big players all have gradual typing. They don't know what they're missing.

I have no problem with dynamically-typed languages, my main problem with Python is the significant whitespace. I really do not like it. I can deal with everything else in Python, or any other programming language, but significant whitespace is what kills it for me.

do you mean requirement of whitespace or how much space that takes up? Because you can change how many spaces python needs for its indentation to get some reduction in whitespace

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

#336
I recently switched to python as well, I went pure nodejs because JS is everywhere and its handy to know. Doing frustratingly, front and back end dev on personal projects gave me a lot of frustration and living in a firefox/chromium Console

I asked Gemini code to generate the same skeleton stuff I was coding in nodejs, and did it perfectly in 1/8 of the code required. python's been maintained for years and is honestly a really easy syntax.

for OS level things, python makes sense and is the defacto. right now I vibe code and skeletons and then determine what I want to add and add it manually.

I'm enjoying the switch, maybe not as hardcore of a dev as many of you but it gives me the fix of having an engineering mind and being able to test things on the fly since I live in a terminal anyways.

I agree with all the points. I do like however that I can do:

def functionHere(something: str, someNumberOrSomething: int)

Seeing all the "uv has made me want to use python again" posts got me in to it. glad I did.

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

#337

Earlier quoted context omitted.

You should always use virtual envs. They're a single directory, how are they an abyss? Pip now complains if you try to install a package system wide.

For shadow IT, anything that requires "installation" vs. being in the base system or being added as a file to a project is an inconvenience. It's why I like using Bottle for small Python frontends: download the file and import. (I'm ranting based on personal experiences with IT in the past. Yes in general virtualenv is the baseline)

Compile python to executable is always an option.

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

#338
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…

This is nitpicking, but this is a good usecase for the := operator: if not (API_KEY := os.getenv("API_KEY")): ... For internal tools I just let os.environ["API_KEY"] raise a KeyError. It's descriptive enough.

[deleted]

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

#339
post #132

Earlier quoted context omitted.

Funnily enough, just starting your class method/variable name with __ does do magic things as a pseudo-keyword. Specifically, it mangles the name for callers outside of that class -- `self.__foo` would need to be accessed as `obj._ClassName__foo`. It's python's approach to having private methods, while remaining somewhat ideologically opposed to them existing. This doesn't apply to the dunder methods, though. They're…

What's the use case for __foo -> _ClassName__foo? I've used python a bunch but never this feature, so I'm curious.

It prevents accidentally overriding the member in subclasses which can prevent private implementation details of parent classes from being accidentally interfered with by child classes.

As composition over inheritance becomes more idiomatic, there are probably less places where this matters, but as long as inheritance is used at all it can be useful.

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

#340
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…

can you give at least one example? You are probably just expecting too much. No manual checkout/install process is easy as installing an application.
Post reply on HN