Live data from Hacker News

How to Write the Worst Possible Python Code (Humor)

effective-programmer.com

11–20 of 31 posts

Re: How to Write the Worst Possible Python Code (Humor)

#11

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. Als…

I came across something quite similar. Using eval to convert a string to a dict. The string potentially included user input.

Re: How to Write the Worst Possible Python Code (Humor)

#12
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.

Re: How to Write the Worst Possible Python Code (Humor)

#13
> 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.

Re: How to Write the Worst Possible Python Code (Humor)

#14
post #13

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

Classic listicle trick: All the obvious ones and one random controversial hot take to get the engagement going.

Re: How to Write the Worst Possible Python Code (Humor)

#15
post #13

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

Jokes on you, the article is ai written

Re: How to Write the Worst Possible Python Code (Humor)

#16
post #3

Disappointed that my favorite pythonic pattern of "here's a dict with unknown contents, do the right thing with it" is not listed.

It's not just Python. You see this a lot in Javascript and Groovy too.

Really I think what makes languages with manual memory management and limited built in types like C nice is it forces people to really think about the types and interfaces they're writing instead of just hacking unmaintainable code at 20 lines an hour.

Re: How to Write the Worst Possible Python Code (Humor)

#17

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. Als…

Yes! India? There is a very big follow the leader culture.

Re: How to Write the Worst Possible Python Code (Humor)

#18

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. Als…

Rhymes with apocryphal monkey-ladder story.
Post reply on HN