Python Beginner to Expert/DebuggingWithIdle
There's more to IDLE than just a editor and command shell. IDLE features a advanced built-in debugger with most features you would expect from any interactive.
Problem the most important features in any debugger are the trace, breakpoint, and watch features. Additionally, a good debugger should allow you to examine variables and objects.
Let's see if IDLE offers all these features.
Here is code to copy and paste into the IDLE editor for this exercise.
import re
#
def isEmail (text):
if (len(text) == 0):
return False
parts = text.split("@")
if (len(parts) != 2 ):
return False
if (len(parts[0]) > 64):
return False
if (len(parts[1]) > 255):
return False
if ( re.search( "gov$", parts[1] ) ):
return False
address = "(^[\\w!#$%&'*+/=?^`{|}~-]+(\\.[\\w!#$%&'*+/=?^`{|}~-]+)*$)"
quotedText = "(^\"(([^\\\\\"])|(\\\\[\\\\\"]))+\"$)"
localPart = address + "|" + quotedText
if ( re.match(localPart, parts[0]) == None ):
return False;
hostnames = "(([a-zA-Z0-9]\\.)|([a-zA-Z0-9][-a-zA-Z0-9]{0,62}[a-zA-Z0-9]\\.))+"
tld = "[a-zA-Z0-9]{2,6}"
domainPart = "^" + hostnames + tld + "$";
if ( re.match(domainPart, parts[1]) == None ):
return False
return True
#
text = "guido@python.com"
if (isEmail(text) ):
print text + " is a valid email address"
else:
print text + " is not a valid email address"
print "done"