import re EMAIL_RE = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$") def is_valid_email(email): return bool(EMAIL_RE.match((email or "").strip()))