Try Except Problem
Victor Subervi
victorsubervi at gmail.com
Tue Sep 1 14:45:39 EDT 2009
Hi:
I have this code:
try:
cursor.execute('select salesperson, office, cell, fax, home, email,
assistant from general where salesperson="%s";' % (catch))
stuff = cursor.fetchone()
test = raw_input('You have selected salesperson %s. Is that correct? (hit
\'enter\' for affirmative, enter anything else for negative): ' % (catch))
if len(test) == 0:
salesperson, office, cell, fax, home, email, assistant = new[i][0],
new[i][1], new[i][2], new[i][3], new[i][4], new[i][5], new[i][6]
print 'one'
except:
print 'two'
salesperson = raw_input('Please enter the sales person\'s name: ')
office = raw_input('Please enter the sales person\'s office number: ')
cell = raw_input('Please enter the sales person\'s cell number: ')
fax = raw_input('Please enter the sales person\'s fax number: ')
home = raw_input('Please enter the sales person\'s home number: ')
email = raw_input('Please enter the sales person\'s email address: ')
assistant = raw_input('Please enter the name of the sales person\'s
assistant: ')
Now, both "one" and "two" get printed! So it's running the try AND the
except!! Why???
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090901/dbbf9dd6/attachment.html>
More information about the Python-list
mailing list