On 10/4/2010 10:38 PM, chad wrote:
Given the following..

#!/usr/bin/python

import urllib2
import sys
import time

while 1:
     try:
         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).

         break
     except:

and guess what this does, and why bare excepts are not recommended unless you mean what you say...

         time.sleep(2)

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to