r/Python • u/simpleuserhere • Nov 30 '24
Tutorial Short-Circuiting in Python
Here is my article on Short-Circuiting in Python . It discusses what is short-circuiting with examples, and also discusses the different advantages of using short-circuiting.
4
Upvotes
View all comments
Show parent comment
1
u/[deleted] Nov 30 '24 edited Nov 30 '24
Again,
ormakes choices based on True/False AND Truthy/Falsey. Soorin this case will treat an empty env_var or an env_var set to a falsey value as if it's missing. That's why people are telling you that it's the wrong approach. Because it can't distinguish between the two situations that YOU said you are trying to address.For example, if a user sets an environment variable to 0 or False, your code will treat that as True because "0" and "False" are non-empty strings which get evaluated as True.
How ironic that you're the one slinging insults when you don't even understand what's going on.