What is a good way to make several attempts to handle one exception in Python?
Question: Let's say, I have a preferred solution to handle exception.  
But exception still occurs sometimes and I have to use the second, less
preferred, solution.  
I use code like the following, it might look not cool. If there is better
practice, please advice.

    
    
    try:
        print(undefined_varible)
    except NameError:
        try:
            print("1st attempt to handle NameError exception")
        except NameError:
            print("2nd attempt to handle NameError exception")
    

UPDATE:  
here is a piece of my real code

    
    
    import re
    def find_phone(text):
        try:
            pattern = re.compile(r"(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?")
            #search for a phone number
            mo = pattern.search(text)
            phone = mo.group()
            print (phone)
        except AttributeError:
            try:
                #don't want to use this pattern always because it's too wide and not perfect
                pattern = re.compile(r"(?:\+?(\d{1,3}))?[-. (]*(\d{1,3})[-. )]*(\d{1,3})[-. ]*(\d{1,4})([-. ]*(\d{1,4}))?([-. ]*(\d{1,4}))?(?: *x(\d{1,4}))?")
                mo = pattern.search(text)
                phone = mo.group()
                print (phone)
            except AttributeError:
                print("phone number has not been found")
    find_phone("here is the weird formatted phone number: +33 6 29 37 24 57")
    


Answer: Suppose you have several ways to check for a phone number. One idea is to have
a counter in your function and through an `if` statement choose which one to
try

    
    
    import re
    def find_phone(text):
        number_of_cases = 2
        i = 0
        while i < number_of_cases
            try:
                if i == 0:
                    pattern = re.compile(r"(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?")
                    #search for a phone number
                    mo = pattern.search(text)
                    phone = mo.group()
                    print (phone)
                elif i == 1:
                    #don't want to use this pattern always because it's too wide and not perfect
                    pattern = re.compile(r"(?:\+?(\d{1,3}))?[-. (]*(\d{1,3})[-. )]*(\d{1,3})[-. ]*(\d{1,4})([-. ]*(\d{1,4}))?([-. ]*(\d{1,4}))?(?: *x(\d{1,4}))?")
                   mo = pattern.search(text)
                   phone = mo.group()
                   print (phone)
            except AttributeError:
                i += 1
            else: break
    

Another thought would be to check if you have found a phone number

