".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

Keith Dart kdart at kdart.com
Thu Dec 16 13:15:43 EST 2004


Steve Holden wrote:
> Nick Coghlan wrote:
> 
>> Roel Schroeven wrote:
>>
>>> Stefan Behnel wrote:
>>>
>>>> This is the first time I see that and I totally like the idea of 
>>>> writing ".>>>" instead of ">>>" at the beginning of a line. Thank 
>>>> you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as 
>>>> the default prompt as it messes up the display on mail/news readers 
>>>> that provide "syntax highlighting" for quotes.
>>
>>
>>
>> I use Thunderbird, and started doing it so I could read my own posts. 
>> I did copy it from someone, though (but I can't recall who).
>>
>> The trick can also be useful for web tools that strip leading whitespace.
>>
>>> Prepending every line with . is not an ideal solution though... I 
>>> think it gets tiresome very quickly.
>>
>>
>>
>> Aye, can't argue with that. It does have the virtues of reliability 
>> and portability, though :)
>>
>> Cheers,
>> Nick.
>>
> $ python
> Python 2.4 (#1, Dec  4 2004, 20:10:33)
> [GCC 3.3.3 (cygwin special)] on cygwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import sys
>  >>> sys.ps1 = ".>>> "; sys.ps2 = ".... "
> .>>> print """\
> .... It isn't that hard"""
> It isn't that hard
> .>>>
> 
> Would it work, I wonder, with a leading space on the prompt? That might 
> be a valid change to the standard prompt. Let's see
> 
>  >>> This line isn't really quoted three times.

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> "

433 $ py
Python> print "This has no leader that screws up email programs."
This has no leader that screws up email programs.
Python>



-- 
                            \/ \/
                            (O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <kdart at kdart.com>
public key: ID: F3D288E4 
============================================================================



More information about the Python-list mailing list