".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
fperez528 at yahoo.com
Fri Dec 17 00:51:23 CET 2004
Kent Johnson wrote:
> Keith Dart wrote:
>> What I do is set Python's sys.ps1 variable to something else. I have a
>> module called "interactive" that I import implicitly by shell alias:
>> py='python -i -c '\''import interactive'\'
>> Which, among other things, sets the prompt to "Python> "
> You can do the same thing using a PYTHONSTARTUP file - see
> You can change the prompts with
> import sys
> sys.ps1 = ' >>> '
> sys.ps2 = ' ... '
You might want to look at ipython:
which provides you automatically with these prompts:
In : for i in range(2):
...: print i,
In : 99*2
In : _2+1
As a curiosity, ipython was actually born as a sys.ps1/2 hack, by assigning to
these objects whose __repr__ would give numbered prompts with results caching.
These days it's a full-blown pure python interpreter, not a $PYTHONSTARTUP
customization anymore, but it's an interesting little historical curiosity.
Especially if you start going very far with interactive customizations, you
might not want to rewrite all of ipython's 15K lines of code :)
More information about the Python-list