Skip to content

Conversation

@swietmon
Copy link
Contributor

No description provided.

return False
else:
return True

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W391 blank line at end of file

@swietmon
Copy link
Contributor Author

@adziu lesson12 ready for review

Copy link
Collaborator

@adziu adziu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coin toss has a minor error. The email regex has a dangerous error for production code, but it shows understanding of regular expressions. If you have time, you can fix those, but I can accept that.

guess = ''

toss_int = random.randint(0, 1) # 0 is tails, 1 is heads
if toss_int == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a short form for that toss = 'tails' if toss_int else 'heads'

print('You got it!')
else:
print('Nope! Guess again!')
guess = input()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't check the validity of input here. To avoid repeating the code you could enclose the while in a function.



def pass_checker(some_password):
if re.match(r'^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{8,}$',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting solution! In all the other reviews multiple regular expressions were used. 👍

regex_text = re.compile(reg)
logging.info("Regex = {}".format(regex_text))
files_list = os.listdir(folder)
logging.info("Files: {}".format(files_list))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to use logger that knows where you are. That is logger = logging.getLogger(__name__) at the beginning of the file and then logger.info(blah).



def email_validator(some_email):
email_regex = re.compile(r"[^@]+@[^@]+\.[^@]+")
Copy link
Collaborator

@adziu adziu Jul 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more complicated than that. Not all the symbols are allowed. In real life you should search Google for "regex library" and get a comprehensive checker or use some library checker (Django for example has a field for that). In less real life situations you should take care that you accept a reasonable subset with _ . etc., but certainly not too much.

You accept too much. The input you accepted could cause some trouble. For example didn't put $ at the end, so the potential attacker could put something in the content of the mail message you are sending. You also accept spaces/inequality characters, semicolons, all rather dangerous, somebody could destroy your CSV file. [\w\d_.-]+ [a-z0-9_.-]+ would be much better than [^@]+ here. In other cases the [^ construct is the best way to go and good that you know it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants