Possible Duplicate:
tell whether python is in -i mode
Tell if python is in interactive mode
Is there a way to check whether a python script has been run with the interactive option -i?
e.g.
if interactive_mode:
print 'I am in interactive mode!'
else:
print 'I am in batch mode!'
Then call with
python hello_world.py
I am in batch mode!
python -i hello_world.py
>> I am in interactive mode!