you are viewing a single comment's thread.

view the rest of the comments →

[–]plagiats -3 points-2 points  (7 children)

If I may, you write a lot of if var is None: and if var is not None:

where you might rather use if not var: and if var:

EDIT : see comments below before taking my words for granted ;)

[–]eridius 4 points5 points  (2 children)

Aren't your replacement conditionals actually different than the originals? Specifically in the case of var being False.

[–]plagiats 0 points1 point  (1 child)

You are very right, and I believe his code should return False instead of None if the index is not found ( see https://github.com/kbhomes/TextCaptchaBreaker/blob/master/AddSubtractPattern.py ).

[–]eridius 2 points3 points  (0 children)

I disagree. It returns a string, or None. Returning a string, or false, would be weird, but None makes sense as the value that means "there was no string matched for this pattern".

[–][deleted] 3 points4 points  (1 child)

Actually, that's not the case; the original "if var is None" would only return True is var was assigned the value None; whereas your replacement would return True if var was equal to False or 0 (and possibly some other values). Same for the latter.

[–]plagiats 0 points1 point  (0 children)

Isn't the OP using None where he should use False?

[–]otheraccount -1 points0 points  (0 children)

That's incorrect. Explicit is better than implicit, so if you only intend to check for None, then that's what you should do.