The problem with this in the OP is the first ‘if’ checks if the object exists and the second gets a property of said object only if the original object exists.
I’m not saying the OP is good code, but chaining them like this would result in exceptions.
The language is python and it has short circuiting aka in an and condition, if the first block isn’t fulfilled the second one isn’t tested because it’s unnecessary.
kernelle@0d.gs 1 month ago
The problem with this in the OP is the first ‘if’ checks if the object exists and the second gets a property of said object only if the original object exists.
I’m not saying the OP is good code, but chaining them like this would result in exceptions.
rothaine@lemm.ee 1 month ago
Not in a language with short circuiting.
kernelle@0d.gs 1 month ago
Could’ve sworn I’ve had this issue before! Maybe not with python
rothaine@lemm.ee 1 month ago
Yeah not all languages do it. I find it rather convenient though
fushuan@lemmy.blahaj.zone 1 month ago
The language is python and it has short circuiting aka in an and condition, if the first block isn’t fulfilled the second one isn’t tested because it’s unnecessary.
Same with or and the reverse.