is_interactive¶
- is_interactive()[source]¶
Detect if the current environment is interactive.
- This should return True for the following environments:
Python REPL ($ python)
IPython REPL ($ ipython)
Interactive Python shell ($ python -i)
Interactive IPython shell ($ ipython -i)
IPython passed a string ($ ipython -c “print(‘Hello’)”)
- Notebooks
Jupyter ($ jupyter notebook)
Google CoLab
Kaggle Notebooks
Jupyter lab ($ jupyter lab)
VSCode Python Interactive window (# %% cells)
VSCode Jupyter notebook environment
PyCharm Console
- This should return False for the following environments:
Python script ($ python script.py)
Python passed a string ($ python -c “print(‘Hello’)”)
PyCharm Run
PyCharm Run (emulate terminal)
- Returns:
True if the current environment is interactive, False otherwise.
- Return type: