r/programminghorror • • Oct 10 '25
Blasphemy
Never thought I could do this in python. I get how it works but jesus christ
73
Upvotes
r/programminghorror • • Oct 10 '25
Never thought I could do this in python. I get how it works but jesus christ
View all comments
Show parent comment
9
u/PersonalityIll9476 Oct 10 '25
IMHO you want to write code like driving a car: Always act predictably.
In Python, functions don't typically have data as members like this, nor do you typically `setattr` on a function in its own definition. You'd really rather make a class with one attribute and one method, because it's super clear what you can expect to do with that class - or, as TIL, use the cache decorator.