I would prefer to do:
import sys
print('Running IDLE' if 'idlelib.run' in sys.modules else 'Out of IDLE')
More Related Contents:
- How can I read inputs as numbers?
- Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]
- IPython Notebook locale error [duplicate]
- Why is parenthesis in print voluntary in Python 2.7?
- Implement MATLAB’s im2col ‘sliding’ in Python
- Enable Python to Connect to MySQL via SSH Tunnelling
- converting currency with $ to numbers in Python pandas
- How to print a list with integers without the brackets, commas and no quotes? [duplicate]
- RuntimeError: module compiled against API version a but this version of numpy is 9
- Selenium – MoveTargetOutOfBoundsException with Firefox
- Strip spaces/tabs/newlines – python
- Logging variable data with new format string
- importing a module when the module name is in a variable [duplicate]
- Python setting Decimal Place range without rounding?
- OverflowError Python int too large to convert to C long
- What does from __future__ import absolute_import actually do?
- Test if an internet connection is present in python
- Cannot use Requests-Module on AWS Lambda
- Running Cython in Windows x64 – fatal error C1083: Cannot open include file: ‘basetsd.h’: No such file or directory
- How do you get all classes defined in a module but not imported?
- PyOpenGL glutInit NullFunctionError
- filter items in a python dictionary where keys contain a specific string
- How to read the last line of a file in Python? [duplicate]
- How to save “complete webpage” not just basic html using Python
- python 2.7 equivalent of built-in method int.from_bytes
- How can I understand a .pyc file content
- Auto-Loading a module on IPython startup
- Unknown error: Chrome failed to start: exited abnormally
- pprint dictionary on multiple lines
- How does all() in python work on empty lists