this post was submitted on 04 Nov 2024
109 points (96.6% liked)

Programmer Humor

32386 readers
692 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 10 points 3 days ago (5 children)

I helped a friend debug a script last week that was working inconsistently in really weird ways. I looked at the script and it was all event hooks littered with sleep calls. I told him he was basically fuzz testing his own script and then getting surprised when he found race conditions. Shit was wild. Also, sometimes getters in Python are a mistake.

[–] [email protected] 4 points 3 days ago (1 children)

Aren’t setters and getters discouraged in Python?

I remember reading something like, “This isn’t C++ , and Python doesn’t have private vars. Just set the var directly.”

[–] [email protected] 2 points 3 days ago

In the way that’s common in languages like Java where you’re making a property read-only, yes. But there’s a whole protocol in Python called descriptors where you can override the . on a field. The most common form of these is class methods annotated with the @property annotation, which makes it so the method can be accessed as if it were a property.

load more comments (3 replies)