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 16 hours 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.
fushuan@lemmy.blahaj.zone 1 hour 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.
rothaine@lemm.ee 15 hours ago
Not in a language with short circuiting.
kernelle@0d.gs 15 hours ago
Could’ve sworn I’ve had this issue before! Maybe not with python
rothaine@lemm.ee 13 hours ago
Yeah not all languages do it. I find it rather convenient though