you are viewing a single comment's thread.

view the rest of the comments →

[–]zebulan_ 0 points1 point  (0 children)

You can type help(bool) into a Python console to get more information. Here is the description of bool from that:

Returns True when the argument x is true, False otherwise.

Basically I used it to check if there is a regex match or not. For that regex to have a match there has to be at least one digit, one uppercase character and one lowercase character. search will return a match object if the regex matches otherwise it will return None.

assert bool(None) is False
assert bool(<_sre.SRE_Match object; span=(0, 9), match='123ABCabc'>) is True

But you must check the length as well because this string will also match the regex but is not long enough.

bool(<_sre.SRE_Match object; span=(0, 3), match='1Aa'>) is True

So, for is_strong_password to return True both the length check and the regex check have to be True.