Skip to content

Commit

Permalink
Updated to Python 3.
Browse files Browse the repository at this point in the history
In order to preserve compatibility with Python 2, raw_input was preserved.
  • Loading branch information
berislavlopac committed Oct 12, 2014
1 parent e5f8797 commit 1777ca0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import logging
import socket

try:
raw_input
except NameError:
def raw_input(prompt=''):
return input(prompt)

try:
import DNS
ServerError = DNS.ServerError
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -191,11 +197,11 @@ def validate_email(email, check_mx=False, verify=False, debug=False, smtp_timeou

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)

Expand Down

0 comments on commit 1777ca0

Please sign in to comment.