Question

I'm writing a program that connects to my website via ftp. If the login authentication fails, I want it to continue on to do something else. But an authentication failure error automatically exits the program. Is there a way to ignore this and continue on?

Was it helpful?

Solution

You can use Python's Exception Handling:

try:
    do_something()
except Exception, ex:
    print "The process failed because", ex
    do_something_else()

replace do_something() with code you first want to try.. Replace do_somthing_else() code with what you wish to try when do_something() part fails

Reference for Exception Handling

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top