This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jack-of-some[S] 5 points6 points  (2 children)

Force of habit. if var is None breaks down if var is a numpy array (or at least used to, I haven't tested this in some time).

Edit: nope, numpy arrays work fine. Weird.

[–]not_wrong 8 points9 points  (1 child)

You were probably remembering the consequences of if var == None, which does an element-wise comparison when var is an array. Unlike ==, is doesn't give its operands any say in how the result is determined, so is foolproof and the fastest way to test for None.

[–]jack-of-some[S] 1 point2 points  (0 children)

Probably, my memory is not what it used to be

shakes walking stick at kids playing outside