SiteMap  | About    

Python pass Statement

The pass statement performs no action and serves as a placeholder in Python. It can be used when a statement is required syntactically but the program requires no action . Python has the syntactical requirement that code blocks after if, except, def, class etc. cannot be empty . The interpreter will produce IndentationError if the above mention code blocks are left empty.


In the example above, when the python interpreter encounters the pass statement , it simply continues with its execution as it normally would. If you would leave out the pass statement in test_method_1(), the code wouldn't run and you will get an IndentationError .

The Python pass statement is a null operation; nothing happens as pass statement is executed and it just passes execution to the next statement . However, the interpreter reads it and so if placed in functions, if statement, loops etc. this is taken as a statement. (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.