From 1777ca0a3083cc8385919724292a6784ce3e359f Mon Sep 17 00:00:00 2001 From: Berislav Lopac Date: Sun, 12 Oct 2014 19:51:42 +0100 Subject: [PATCH] Updated to Python 3. In order to preserve compatibility with Python 2, raw_input was preserved. --- validate_email.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/validate_email.py b/validate_email.py index 6d945a8..2823f72 100644 --- a/validate_email.py +++ b/validate_email.py @@ -22,6 +22,12 @@ import smtplib import logging import socket +try: + raw_input +except NameError: + def raw_input(prompt=''): + return input(prompt) + try: import DNS ServerError = DNS.ServerError @@ -94,7 +100,7 @@ def get_mx_ip(hostname): if hostname not in MX_DNS_CACHE: try: MX_DNS_CACHE[hostname] = DNS.mxlookup(hostname) - except ServerError, e: + except ServerError as e: if e.rcode == 3: # NXDOMAIN (Non-Existent Domain) MX_DNS_CACHE[hostname] = None else: @@ -191,11 +197,11 @@ if __name__ == "__main__": result = validate_email(email, mx, validate, debug=True, smtp_timeout=1) if result: - print "Valid!" + print("Valid!") elif result is None: - print "I'm not sure." + print("I'm not sure.") else: - print "Invalid!" + print("Invalid!") time.sleep(1)