Post #2203542
2026-05-07 05:29 UTC
Replies (5)
-
@eliocamp@mastodon.social 2026-05-07 06:07
I found a one-liner: `list(Path(path).iterdir())`. It's still rather convoluted and impossible to discover, but at least doesn´t require explicit loops.
-
@gspeed0689@mapstodon.space 2026-05-07 05:36
@eliocamp@mastodon.social just addressing the example py code and not the article or idea of python being bad for this, there is a nicer way now with Pathlib path = pathlib.Path(path) files = list(path.rglob("*"))
-
@bmaxv@noc.social 2026-05-07 05:49
@eliocamp@mastodon.social Hmmm. Yes. Of course it could be that your brain simply can't contain the vast(!) intellect required to write python. That's not your fault, it's a skill that can only be acquired by studying in a sufficiently pure field. Please consult the chart: https://xkcd.com/435/ Yes that was sarkasm. This is serious: I don't like that example. Don't use list comprehensions like that.
-
@jimgar@hachyderm.io 2026-05-07 07:29
@eliocamp@mastodon.social This isn’t apecific to your issue, but I’ve read Python people saying list comprehensions are easier to read than for loops. I simply cannot understand how that’s possible.
-
@drgroftehauge@sigmoid.social 2026-05-07 10:47
@eliocamp@mastodon.social Why on earth is files a method on the list class? And what do you do if you have 5 million files you want to do something to?