Stephen Paul Chappell <[email protected]> added the comment:
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('', ' ... ')
----------
nosy: +Zero
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37903>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com