done=False while not done: try: urllib.urlretrieve(myurl,myfile) except: pass else: done=True