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

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

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

html - jQuery UI Sortable - Remove placeholder after item is dropped -