# -*- coding: utf-8 -*- import re domain_re = re.compile(r'^(?!-)[a-z0-9-]{1,63}(? 0 and port < 65536 except: return False def is_valid_email(email): parts = email.split('@') if len(parts) != 2: return False return bool(box_re.match(parts[0])) and bool(domain_re.match(parts[1]))