Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catching all exceptions without pylint error

import traceback

def func():
    try:
        -- do something --
    except:
        traceback.print_exc()

For this code
pylint reporting error: bare-except No exception type(s) specified , W0702, Occurs when an except clause doesn't specify exceptions type to catch.

Now, if I want all exceptions to be captured without pylint error. Is there a way.
Please help.
Thanks

like image 609
sanapala mohanarao Avatar asked Nov 30 '22 21:11

sanapala mohanarao


1 Answers

I prefer using this more meaningful style:

def func():
    try:
        -- do something --
    except: # pylint: disable=bare-except
        traceback.print_exc()
like image 62
Jack Avatar answered Dec 04 '22 05:12

Jack