Message355752
The documentation for sys.ps1 and sys.ps2 states that they "are only defined if the interpreter is in interactive mode." Since the IDLE shell is meant to be interactive (and to reduce the differences between the shell and running Python directly), would it be helpful if ps1 and ps2 were defined when running IDLE? The shell could then honor their values.
If such a direction was explored, one issue may be that the sidebar could not simply be 3 char wide. The documentation also states that non-strings are evaluated each time they are needed by the interpreter. This allows for such interesting possibilities as shown with the code below but may not be desired functionality for the IDLE shell window.
import sys
from datetime import datetime
class TimePrompt:
def __init__(self, prefix, suffix):
self.prefix, self.suffix = prefix, suffix
def __str__(self):
return f'{self.prefix}{datetime.now()}{self.suffix}'
sys.ps1, sys.ps2 = TimePrompt('', ' >>> '), TimePrompt('', ' ... ') |
|
Date |
User |
Action |
Args |
2019-10-31 13:58:26 | Zero | set | recipients:
+ Zero, terry.reedy, taleinat |
2019-10-31 13:58:26 | Zero | set | messageid: <1572530306.56.0.503593621523.issue37903@roundup.psfhosted.org> |
2019-10-31 13:58:26 | Zero | link | issue37903 messages |
2019-10-31 13:58:26 | Zero | create | |
|