Lin Ma Lin Ma - 1 year ago 235
Python Question

strange exceptions.SystemExit in Python 2.7

Here is my code and error message, anyone have any ideas why there are such exception? Thanks.

Source Code,

import sys
import tensorflow as tf

def main(argv):
print 'in main'
def f():
# this method will call def main(argv)
print " error ", sys.exc_info()

if __name__ == "__main__":

Error Code,

in main error (<type 'exceptions.SystemExit'>, SystemExit(), <traceback object at 0x10fa33f38>)

Answer Source

This is expected behavior: passes the result of main() to sys.exit() (to make it easier to set an edit code), and sys.exit() raises an exceptions.SystemExit exception.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download