Open genghis opened 4 years ago
Thanks, @genghis. I'd definitely considered this. I've grown accustomed to using Yoda conditions because they're part of the WordPress coding standards, and it looks like the Symfony coding standards as well. They're intended to protect against accidental variable reassignment which, if undetected, can lead to unexpected behavior.
I'm coding against the PEP8 standards within PyCharm, which doesn't throw any warnings when using a Yoda conditional. I'd be interested in researching this some more to find out whether there is any community discussion around it. I'll follow up here when I find out more.
I love that term, Yoda conditions. Thanks for that!
This is more what I've seen conventionally:
All the python I've been exposed to flips your standard way of doing
if
checks--Yours:
if 'POST' == request.method:
What I have seen:
if request.method == 'POST':
This is UTTERLY unimportant and frankly your way makes it very slightly quicker to realize what you're checking for, so maybe it's not a thing to change. My bet is that it makes it obvious that you're not coming from a Python background (which is probably fine)