Discussions on Python.org
Detect if interactive or script mode
Python Help
inventshah
(Sachin S)
June 10, 2026, 4:44pm
6
I have used
hasattr(sys, "ps1")
many times in the past for this purpose
show post in topic