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

javascript - Create websocket without connecting -

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

Android SDK Manager freezes after installation of OSX 10.11 El Capitan public Beta -