To give one concrete example of an LOL PYTHON consider the @property decorator. While it seems like a really cool and handy idea that could let you save some typing in some cases, it is actually a trap that you should almost never use because when you inevitably discover that there is some parametrization that you need to pass to the ... attribute, you are suddenly faced with a massive refactoring. Also if you ever make the mistake of having boolean properties such as isDir or isUrl and somewhere else you have a predicate that is a function instead of a property then isFile will always return True when you meant isFile(). The only safe solution is to never use properties/attributes as predicates. These are nasty footguns that seem obscure and unlikely to affect you until you have the misfortune to already be in the briar patch.
0. https://github.com/search?q=%22LOL+PYTHON%22+user%3Atgbugs&t...
class Here:
@property
def booleanPredicate(self):
return random_bool()
class There:
def anotherBooleanPredicate(self):
return random_bool()
here = Here()
there = There()
What happens in the following cases? here.booleanPredicate # as expected
here.booleanPredicate() # loud failure
here.anotherBooleanPredicate # silently always True
here.anotherBooleanPredicate() # as expected
So you might think that you should _always_ use @property for boolean predicates, except that there are libraries that use the anotherBooleanPredicate version so you are now at risk for silent always True behavior (creeping sanity destroying evil behavior). To prevent the silent failure you should always start by calling the predicate so that it can fail loudly. Worse if someone does a refactor and misses going from @property form to function form then the silent failure literally cannot be detected by running the program (!).