A use-case for for...else with no break

Steve D'Aprano steve+python at pearwood.info
Fri Nov 3 09:59:09 EDT 2017


On Fri, 3 Nov 2017 09:13 pm, Serhiy Storchaka wrote:

> What the interpreter or configuration do you use? The standard
> interpreter uses '>>> ' as a prompt.

I have this in my Python startup file:

if (sys.version_info[0] >= 3 and os.name == 'posix'
        and os.environ['TERM'] in ['xterm', 'vt100']):
    # Make the prompt bold in Python 3.
    sys.ps1 = '\001\x1b[1m\002py> \001\x1b[0m\002'
    sys.ps2 = '\001\x1b[1m\002... \001\x1b[0m\002'
else:
    sys.ps1 = 'py> '



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list