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
Post a Comment