Live data from Hacker News

What new Python features are the most useful for you?

news.ycombinator.com

41–44 of 44 posts

Re: What new Python features are the most useful for you?

#41
post #2

- einops (probably by far the most useful Python dsl for me as of late, esp. if you deal a lot with tensors) - numpy __array__ interface standardization (easy compatibility across a lot of numerical libraries, e.g. torch, awkward-array, zarr, jax.numpy, dask, xarray) - the various jit compilers (e.g. numba, jax.jit, torch.compile) - hw-accelerated functional programming style (e.g. functorch.vmap) - pybind11 for easy…

Matplotlib is really killing me. I never have learned it properly and switch between methods to address the same things in Matplotlib. Every time I have to plot something I have to Google how to do it or I have a template ready already. In my opinion it’s the most annoying library I have to use.

Altair/Vega ( https://altair-viz.github.io/ ) is really nice to use, although headless rendering outside of a notebook environment is a bit of a pain

Re: What new Python features are the most useful for you?

#42

Earlier quoted context omitted.

Matplotlib is really killing me. I never have learned it properly and switch between methods to address the same things in Matplotlib. Every time I have to plot something I have to Google how to do it or I have a template ready already. In my opinion it’s the most annoying library I have to use.

Altair/Vega ( https://altair-viz.github.io/ ) is really nice to use, although headless rendering outside of a notebook environment is a bit of a pain

I‘m not working inside of notebooks too much to be honest. I was doing so a while back but working in a modular fashion with other scripts is a pain so I went back to vanilla Python files in VS Code a while back. I’ll still take a look, thanks for the heads up!

Re: What new Python features are the most useful for you?

#43
post #38
post #32

Earlier quoted context omitted.

OK, it's 100% likely I saw it, just so rarely I can't remember. Testing. Over that long time I have used many test frameworks. My normal workflow is to try and exercise all the code I write as I go. On the other hand I am 100% pedantic about using 'schema' ( https://pypi.org/project/schema/ ) to validate all the types, structure and domains when I read json.

Nearly the same here. The only type error I make a little bit more than I would like, is expecting an iterable and passing a string instead, because I forgot parentheses around arguments. But I made way more type errors when programming in C/++. Why do you prefer schema to (fast)jsonschema?

'schema' is more a schema enhanced by python than just a checker. It can convert types, set defaults so after 'Box' I can simple access config with a.b.c. It may be subtle but it is much more powerful than it looks.

There are many of these things. Maybe some are better but I like this one.

Re: What new Python features are the most useful for you?

#44
post #6

The `click` library would be a nice replacement to `argparse`

"Click" and "DocOpt" are the 'argparse' replacements. They're the most semantic and intuitive way of developing command-line apps.

Thanks for sharing Typer, I was completely oblivious!

> Typer uses Click internally. That's the only dependency.

Pretty clever way to walk on giants shoulders!

Post reply on HN