I don't get why sys.exit(1) doesn't exit the while loop in the follow case
tjreedy at udel.edu
Tue Oct 5 05:02:18 CEST 2010
On 10/4/2010 10:38 PM, chad wrote:
> Given the following..
> import urllib2
> import sys
> import time
> while 1:
> con = urllib2.urlopen("http://www.google.com")
> data = con.read()
> print "connected"
> #The loop doesn't exit if I use sys.exit(1)
Guess how sys.exit is implemented (or check the fine library manual
chapter on the sys module, .exit entry, 2nd sentence).
and guess what this does, and why bare excepts are not recommended
unless you mean what you say...
Terry Jan Reedy
More information about the Python-list