[issue37903] IDLE Shell sidebar.

Stephen Paul Chappell report at bugs.python.org
Thu Oct 31 09:58:26 EDT 2019


Stephen Paul Chappell <Noctis.Skytower at gmail.com> 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 <report at bugs.python.org>
<https://bugs.python.org/issue37903>
_______________________________________


More information about the Python-bugs-list mailing list