[Python-ideas] Idea for new multi-line triple quote literal

nbv4 nbvfour at gmail.com
Mon Jul 1 04:52:17 CEST 2013


I wanted to make sure the text I was posting was being rendered in fixed 
width font, hence the gist.

On Sunday, June 30, 2013 6:47:29 PM UTC-7, Nick Coghlan wrote:
>
> On 1 July 2013 11:09, Steven D'Aprano <st... at pearwood.info <javascript:>> 
> wrote: 
> > but in either case, I think the choice of --- as delimiter is ugly and 
> > arbitrary, and very likely is ambiguous (currently, x = ---1 is legal 
> code). 
> > Similar suggestions to this have been made many times before, you should 
> > search the archives: 
> > 
> > http://mail.python.org/mailman/listinfo/python-ideas 
>
> I'm still partial to the idea of offering textwrap.indent() and 
> textwrap.dedent() as string methods. 
>
> 1. You could add a ".dedent()" at the end of a triple quoted string 
> for this kind of problem. For a lot of code, the runtime cost isn't an 
> issue. 
> 2. A JIT would definitely be able to avoid recalculating the result every 
> time 
> 3. Even CPython may eventually gain constant folding for that kind of 
> method applied directly to a string literal 
> 4. I dedent and indent long strings more often than I capitalize, 
> center, tab expand, or perform various other operations which already 
> grace the str type as methods. 
>
> Cheers, 
> Nick. 
>
> -- 
> Nick Coghlan   |   ncog... at gmail.com <javascript:>   |   Brisbane, 
> Australia 
> _______________________________________________ 
> Python-ideas mailing list 
> Python... at python.org <javascript:> 
> http://mail.python.org/mailman/listinfo/python-ideas 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130630/6e0ff0dd/attachment.html>


More information about the Python-ideas mailing list