skaller wrote:
> It opens up the issue of what
> to do with string literals. In Python it is very painful,
> because the literals don't support nice block indent style.
>
> In this case .. attempts to make the code look nice
> turn out to cause a bug. AFAICR trailing whitespace
> is elided (because you can't see it). Thus
>
> """hello
> """
>
> will be 'hello\n' even if you put extra ' ' after hello.
> If you put 
>
> """hello   \
> """
>
> it adds the white space .. but removes the \n ... ;(
>
> Not very consistent..

There's been a library, textwrap, since python 2.3 to work around this:

import textwrap

def foo():
    s = """\
    hello hi ho
    hee
      la la la"""

    print s
    print '*' * 50
    print textwrap.dedent(s)

foo()


which will print:

    hello hi ho
    hee
      la la la
**************************************************
hello hi ho
hee
  la la la


We could easily copy this in the String module.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to