0

I know there is a way I should use try catch (try - except) concept to hide any error or warning.

But is there a recommended way to hide all or any python error like PHP use error_reporting() function to hide any error instead of using try block that encapsulate main program.

My Python script has been obfuscated by pyarmor. The problem is, if there is an error, it shows my script code partially where that error came.

ShoeLace
  • 3,476
  • 2
  • 30
  • 44
  • Hide traceback unless a debug flag is set; https://stackoverflow.com/questions/27674602/hide-traceback-unless-a-debug-flag-is-set – pippo1980 Feb 05 '22 at 23:14

1 Answers1

0

I don't think it's possible. If the program raises an exception, your options are to catch that exception somewhere, or have the program crash.

For example:

dwarves = ["Sleepy", "Sneezy", "Wheezy", "Breezy", "Goofy", "Bashful", "Doc"]
target = dwarves[8] #IndexError!
print(target) # print what?

How can the program continue if you're not handling the error?

Jack Deeth
  • 3,062
  • 3
  • 24
  • 39