Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

301–310 of 718 posts

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

#301

Earlier quoted context omitted.

Bizarre is that you don’t consider it ugly. Kotlin: constructor is either part of class definition or keyword constructor. Ruby: initialize JS: constructor Python: ______new______, _______init_______ Literally this meme: https://knowyourmeme.com/memes/three-headed-dragon

I would think the dumber thing is having to create an empty file called __init__.py for a package to register as a package. And relative imports being completely fubar.

> I would think the dumber thing is having to create an empty file called __init__.py for a package to register as a package.

This hasn't been true since Python 3.3. You no longer need a __init__.py for Python to recognize a module, but it can still be useful in many cases.

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

#302

I make projects following almost identical patterns. It's a little uncanny. Maybe the people in the python developer ecosystem are converging on a pretty uniform way to do most things? I though some of my choices were maybe "my own", it seeing such consistency makes me question my own free will. It's like when people pick a "unique" name for their baby along with almost everyone else. What you thought was a unique na…

as though subsurface pilot waves in every spectrum hold human egos as constituent particles - becoming-being lol

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

#303

Earlier quoted context omitted.

Bizarre is that you don’t consider it ugly. Kotlin: constructor is either part of class definition or keyword constructor. Ruby: initialize JS: constructor Python: ______new______, _______init_______ Literally this meme: https://knowyourmeme.com/memes/three-headed-dragon

That's kind of the point. These methods are never meant to be called directly. They're used to desugar. I think it's fairly short sighted to criticize these. FWIW, I also did that the first time I wrote Python. Other languages that do similar things provide a useful transparency.

I don’t think anyone is criticizing its utility, just that the syntax of 2-5(?) underscores in a row isn’t something that is DX friendly.

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

#304
post #238

Earlier quoted context omitted.

I have had a somewhat unearned distaste for Python for the last decade or so. I mostly just don’t like some of the design decisions it made. I don’t like that lambdas can’t span multiple lines, I don’t like how slow loops are, I don’t like some functions seem to mutate lists and others don’t, and I am sure that there are other things I missed. But it really comes down to the fact that my career hasn’t used it much. I…

The most insane python feature is that for loops keep their intermediate variable. for x in [1,2,3]: print(x) x sticks around! So you'll always have these random variables floating around, and hope you don't use the wrong one. And to add insult to insult to injury, if you're using mypy for type checking you'll get a nice error if you try to reuse x with a different type: for x in ['a', 'b', 'c']: print(x) And the typ…

> The most insane python feature is that for loops keep their intermediate variable.

"Insane feature" is a generous way of describing this behavior. I would say it is just a stupid bug that has managed to persist. Probably it is impossible to fix now because of https://xkcd.com/1172/

How typecheckers and linters should deal with this is a tricky question. There is how the language ought to work, and then there is how the language actually does in fact work, and unfortunately they are not the same.

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

#305
post #196

Earlier quoted context omitted.

> However, uv has, at least for my beginner and cynical eyes, swept away most of the bullshit for me. uv is _much_ better than what came before. As someone who has only had only glancing contact with Python throughout my career (terrible experiences at jobs with conda and pip), uv feels like Python trying to actually join the 21st century of package management. It's telling that it's in Rust and clearly takes inspira…

The funniest thing for me is that you can use uv in mise to install Python cli programs in a surprisingly elegant manner.

Just curious: how?

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

#306
post #285

Earlier quoted context omitted.

If I were to try again I'd go with uv, it seems way way better

I have been sticking with poetry for a while, now. What would make me want/need to move to uv?

Maybe you'll find this series of articles interesting: https://www.loopwerk.io/articles/tag/uv/

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

#307
post #68

Earlier quoted context omitted.

flatpak, docker ? i.e. include an almost complete distribution just to make one package work? but what if you want that package to work in the distribution you have now? What if you need 2 different packages that are in different flatpacks or different docker images?

Set them up, each in its own container, and use GRPC to communicate between them... (Not even kidding, I've seen people do this)

Goodness gracious!

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

#308

> 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-optimizations --with-lto

4. run make -s -j [num cores]

5. sudo make altinstall

This will install that specific version without overwriting default system python.

You can then bash alias pip to python3.xx -m pip to make sure it runs the correct one.

All the libraries and any pip install executable will be installed locally to ~/.local folder under the specific python version.

Alternatively, if you work with other tools like node and want to manage different versions, you can use asdf, as it gives you per folder version selection.

virtual environments are really only useful for production code, where you want to test with specific versions and lock those down.

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

#309
post #5

> Python has done a good job of hiding its legacy ugliness (such as __init__, __new__, and similar aberrations), swettening its syntax to accomodate developers with good taste. What exactly is the problem with __init__ or __new__? @dataclass is very nice syntactic sugar, but are we arguing here that having access to initializer/allocator/constructor dunder methods is "legacy ugliness"? This is the core of pythonic bu…

Bizarre is that you don’t consider it ugly. Kotlin: constructor is either part of class definition or keyword constructor. Ruby: initialize JS: constructor Python: ______new______, _______init_______ Literally this meme: https://knowyourmeme.com/memes/three-headed-dragon

If you felt your argument about __new__ and __init__ was valid, you probably would have used the actual names and not hyperbolic exaggerations.

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

#310

Earlier quoted context omitted.

That's kind of the point. These methods are never meant to be called directly. They're used to desugar. I think it's fairly short sighted to criticize these. FWIW, I also did that the first time I wrote Python. Other languages that do similar things provide a useful transparency.

I don’t think anyone is criticizing its utility, just that the syntax of 2-5(?) underscores in a row isn’t something that is DX friendly.

The syntax is exactly two, not 2-5.
Post reply on HN