Unreachable code


Used when there is some code behind a return or raise statement, which will never be accessed.


In a method or function, processing of commands stops after a return or raise statement, and control is given back to the code that called the function/method. Any code in a function placed after such a statement will never be accessed.

If we have this function:

def function(value):
    return True
    print value

The code print value is placed after the end of the function (the return statement) and thus will never be executed.

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License