You can use the following methods to ignore exceptions properly:-
It deletes an entire directory argument ‘path’ must point to a directory. If the argument is true, if errors are false or omitted, such errors are handled by calling a handler specified by onerror or, if that is omitted, they raise an exception in that case.
You can explicitly check for the path is a symbolic link and raise OSError in that
Traceback (most recent call last):
OSError: [Errno 2] No such file or directory: '/fake/dir'
except OSError, e:
if e.errno == 2:
# suppress "No such file or directory" error
# reraise the exception, as it's an unexpected error