What is the use of the “-O” flag for running Python?

python -O does the following currently:

  • completely ignores asserts
  • sets the special builtin name __debug__ to False (which by default is True)

and when called as python -OO

  • removes docstrings from the code

I don’t know why everyone forgets to mention the __debug__ issue; perhaps it is because I’m the only one using it 🙂 An if __debug__ construct creates no bytecode at all when running under -O, and I find that very useful.

Leave a Comment

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