Option for python cmd to have interactive behavior

When use in interactive more, the return value of an expression gets printed

>>> 1+1

Is there is there some option to have this behavior when using it as a command?

For example, a flag of configuration to make python -c "1+1" behave as python -c "print(1+1)" would do.

I don’t know any such option. I just looked around in the command line options and env settings docs, and still didn’t find anything. For simple commands you could make your own python :slight_smile:

import sys
import os
from math import *
sys.path[0:0] = os.getcwd()
args = " ".join(sys.argv[1:])
$ ./mypython pi + e
1 Like

No, in batch mode one must explicitly print. Adding -i (before -c is also used) puts python in interactive mode after executing the indicated code in batch mode.