Implement bubble sort in Python
thanks for sharing your code.

There are a few things I wanted to talk about.


You shouldn't try / except an IndexError as a form of control flow.


An IndexError here would be the programmer's mistake, you should make sure that your code can't even raise an IndexError in the first place by using correct conditions in your loops. You can also removed the try/except sections completely and your code still behaves the same way.


Recursion


BubbleSort is an inefficient sorting algorithm when dealing with large inputs. The sheer number of comparisons done with larger inputs will cause some serious problems if you recursively call the function.

With the example input you gave, your function gets called 568 times. I tried sorting a list of double the size and got this

RecursionError: maximum recursion depth exceeded in comparison


Using a more straightforward iterative approach would be much more efficient.

def bubble_sort(details):  
    """compares two consecutive integers in a list and shifts the smaller one to left """
    for i in range(len(details) - 1):
        swapped = False
        for j in range(len(details) - 1):
            if details[j] &gt; details[j+1]:
                temp = details[j]
                details[j] = details[j+1]
                details[j+1] = temp
                swapped = True

        if not swapped:
            break

    return details


sort_me = [11,127,56,2,1,5,7,9,11] * 100 # give it a large input
print sort_me
print bubble_sort(sort_me)


A few additional things, 


Consider implementing a version that doesn't modify the original list, think sorted(list) vs list.sort().
Your current implementation sorts the method in place but also returns the same list. If your method is mutating the list, consider not having a return value (or returning None instead).


Hopefully this was useful for you!