How to write an empty indented block in Python?

Just write

pass

as in

try:
    # Do something illegal.
    ...
except:
    # Pretend nothing happened.
    pass

EDIT: @swillden brings up a good point, viz., this is a terrible idea in general. You should, at the least, say

except TypeError, DivideByZeroError:

or whatever kinds of errors you want to handle. Otherwise you can mask bigger problems.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)