why do we use 'pass' in error handling of python? -


it conventional use pass statement in python following piece of code.

try:   os.makedirs(dir) except oserror:   pass 

so, 'pass' bascially not here. in case, why still put few codes in program? confused. many time , attention.

it's parser. if wrote this:

try:   # code except error: 

and put nothing in except spot, parser signal error because incorrectly identify next indentation level. imagine code:

def f(x):  try:   #  except error: def g(x):  # more code 

the parser expecting statement greater indentation except statement got new top-level definition. pass filler satisfy parser.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -