-5

I have the following written in wing101 and python 3.3.2

def open_page(url):
    """Open the URL string given and return its contents as file."""
    page = None
    increment_num_calls()
    cont = False
    while not cont:
        try:
            page = urllib2.urlopen(url)
            cont = True
        except urllib2.URLError as e:
            print "Warning: Url load error " + str(e) + " for url " + url
            #if not hasattr(e, "code"):
            #    raise
            if hasattr(e, "code") and e.code == 401:
                return None
            time.sleep(TIME_DELAY_PAGE_RETRY)
            return None
        except httplib.BadStatusLine:
            return None
    return page

Can anyone help me figure out the bug the error says

print "Warning: Url load error " + str(e) + " for url " + url

If you want to see any more of the program let me know and I can post it.

Jon Clements
  • 138,671
  • 33
  • 247
  • 280

1 Answers1

1

Print works differently in Python 3

Try changing

print "Warning: Url load error " + str(e) + " for url " + url

to

print('Warning: Url load error {} for url {}'.format(e, url))
Prashant Kumar
  • 20,069
  • 14
  • 47
  • 63