On Tue, Mar 4, 2014 at 11:55 PM, Alexander Blinne <n...@blinne.net> wrote: > Am 03.03.2014 19:48, schrieb Terry Reedy: >> The 'is' operator has three uses, two intended and one not. In >> production code, 'is' tests that an object *is* a particular singular >> object, such as None or a sentinel instance of class object. > > Just a bit of statistics on this one from a recent small project: > > <13:51:20> alex@firefly$ grep ' is ' *.py | wc > 65 415 3234 > <13:51:35> alex@firefly$ grep ' is None' *.py | wc > 43 243 1948 > <13:51:40> alex@firefly$ grep ' is not None' *.py | wc > 21 167 1241 > <13:51:44> alex@firefly$ grep ' is False' *.py | wc > 1 5 45 > > No other uses if 'is' found in almost 3 KLOC...
Lemme spin you up a different way of doing it, which actually looks for the operators. https://github.com/Rosuav/ExceptExpr/blob/master/find_except_expr.py Run across the Python stdlib, that tells me there are 4040 uses of is/is not, of which 16 compare against False, 18 against True (see? Python has a bias for truth above falsehood!), and 3386 against None. The other 620 are probably mostly sentinel objects, but I didn't look at them. ChrisA -- https://mail.python.org/mailman/listinfo/python-list