On Wed, Apr 25, 2018 at 1:56 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote: > On Tue, Apr 24, 2018 at 11:51 AM, Ethan Furman <ethan at stoneleaf.us> wrote: > >>> When I compare to variables from outer scopes they *usually* are on >>> the *right* side of '=='. >> >> >> You mean something like >> >> if 2 == x: >> >> ? I never write code like that, and I haven't seen it, either. > > Hm. I mean this: > > const = 'something' > > def foo(arg): > if arg == const: > do something > > Note that "const" is on the right side of "==". > > Would you write this as > > def foo(arg): > if const == arg: > > ? ;) That's assuming the global is a constant. What if it's a mode-setting marker? def foo(arg): ... if output == "verbose" or (output != "quiet" and error_count): print("Arg foo'd", arg) print("Errors found:", error_count) Then I would definitely put the variable first. And I know a lot of people who would parenthesize the first condition in this. ChrisA
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4