3 ms·
if input_email in valid_emails_set: send_email(input_email, another_param, etc) Their solution, while isn't wrong, could still be improved. With a some
by w-ll 13y ago
if input_email in valid_emails_set:
send_email(input_email, another_param, etc)
Their solution, while isn't wrong, could still be improved. With a somewhat modified 2822 regex with a more strict domain rule. But I would also assume you could just query the db.
- tantalor 13y agoYou assume "in valid_emails_set" doesn't make a query. It's fairly trivial to define your own __contains__ in python.
- masklinn 13y agoIndeed, since this is an internal system validating the uni's own emails it could easily query the uni's MSA for valid addresses. Although for a set of 80k items and long-running processes (fcgi or wsgi) you could also load the whole thing in memory directly and not bother with a custom `__contains__`.
- eru 13y agoI don't see how regular expression come in here. They'd have a list of valid addresses (in a Python dict or in a database or wherever) and they check against them.