Re: Testing for connection to a website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: Testing for connection to a website

    Alexnb wrote:
    e = ''
    try:
    ...
    except HTTPError, e:
    print e.code
    except URLError, e:
    print e.reason
    >
    if e == '':
    print "good to go"
    footnote: here's a better way to test if an exception was raised or not:

    try:
    ...
    except HTTPError, e:
    print e.code
    except URLError, e:
    print e.reason
    else:
    print "good to go"

    </F>

Working...