Hi, I am a Windows 10 user still using Python 2.x (for good reasons, I assure you.)
I have a Python 2.x module that I would like to be able to use in a variety of Python 2.x programs. The module outputs characters to the user that are only available in the Unicode character set. I have found that the selection of characters in that set that are available to my software depends on whether, for example, the program is being run during an IDLE session or at a Command Prompt. I am therefore needing to include logic in this module that (a) enables it to output appropriate characters depending on whether it is being run during an IDLE session or at a command prompt, and (b) enables it to discern which of these two "run environments" it is running in. Goal (a) is achieved easily by using string.replace to replace unavailable characters with available ones where necessary. The best way I have found so far to achieve goal (b) is to use sys.modules and ascertain whether any modules contain the string "idlelib". If they do, that I assume that the software is being run in an IDLE session. I suspect that there is a more Pythonic (and reliable?) way of achieving goal (b). Can anyone please tell me if there is, and, if there is, what it is? Thanks. Stephen Tucker. -- https://mail.python.org/mailman/listinfo/python-list