by xg15 on 6/14/2025, 11:14:18 AM
by Zeppelin1492 on 6/14/2025, 11:10:09 AM
Alternative for rule 1 - give descriptive names to your variables, but then just reuse them throughout the function for all kinds values and purposes. The longer the function the better.
Example
somethingService = ...
somethingService = somethingService.Do()
Really fun to debug.by seanhunter on 6/14/2025, 10:02:35 AM
I once was in the position of becoming pr approver[1] for a team of outsourced python programmers who were under some pretty extreme deadline pressure. Anyway one day a PR comes in and I can’t help but notice it was doing a string eval.
Weird. You almost never need to do string eval in python, and whenever there is something where you think you need eval there is a better and safer way to achieve the same result.
Also, I was bending my brain but I couldn’t really figure out what this eval was for until I wrote out some scratch code myself to figure it out.
Turns out this 5 lines or so was constructing a string to do dict lookup and then evalling that. So say you have a dict d = {‘foo’: ‘bar’} and you have a variable i=foo and want to look up d[i], instead of just doing that it was doing something like
eval(‘d[‘+i+’]’)
Just no.So I rejected the change and they came back with “but we’ve always done it that way”. I grep the codebase and yes. There were about 200+ uses of eval, all of which were constructing a string to look something up in a dictionary and then evaling the result. Some person who clearly didn’t program in python had found this twisted way to look things up in a dictionary and then this team had dutifully copied and pasted it throughout the codebase.
[1] ie I wasn’t there from the start of the project
by ck45 on 6/14/2025, 11:38:10 AM
Double pro tip for naming identifiers: Overwrite built ins; dir, list, len, file, those are all beautiful identifiers and debugging the resulting bugs is twice the fun
by antisol on 6/15/2025, 3:32:52 AM
Well hey there chatgpt! I recognise your writing style anywhere — it's like a bad metaphor where you end up saying "what?".
by photios on 6/14/2025, 9:39:35 AM
Disappointed that my favorite pythonic pattern of "here's a dict with unknown contents, do the right thing with it" is not listed.
by RadiozRadioz on 6/14/2025, 9:42:15 AM
> abandoned packages with no recent commits
So, stable packages?
by in12parsecs on 6/14/2025, 10:38:49 AM
I am teaching python to a group of beginner programmers. This will be shared!
by sim7c00 on 6/14/2025, 10:31:07 AM
oh but theres so much more worse xD... but i guess that goes in general for code. fun read tho and with reverse psychology u can maybe learn something as a novice snake wrangler xD
> Rule #13: AI-Assisted Coding is for the Weak
Me reading this article: yup, yup, yup, yup, wait a minute!
This part feels a bit snuck in, in a "leading and pacing" kind of way: All the other points are long-established no brainers, but this one is still controversially discussed and I'd say - in the general form it's presented here - wrong.
The author is still right that it's wrong to categorically dismiss AI tools when coding. But you'd have to apply a lot more caution to this point than to the others.
I hope sneaking this in wasn't the real motivation of the article.