[Patches] [ python-Patches-578688 ] incompatible, but nice strings improveme

noreply@sourceforge.net noreply@sourceforge.net
Tue, 09 Jul 2002 01:13:26 -0700


Patches item #578688, was opened at 2002-07-08 16:25
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=578688&group_id=5470

Category: Parser/Compiler
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Stepan Koltsov (yozh)
Assigned to: Nobody/Anonymous (nobody)
Summary: incompatible, but nice strings improveme

Initial Comment:
This patch changes interpretation of multiline strings
(desn't matter, single, double quoted (when NL escaped
with backslash), triple quoted).

After applying this patch, first: first charachter
after opening quote is ignored, if it is NL, example:

"""
la-la-la
"""

will be equivalent of

"""la-la-la
"""

First variant looks better, isn't is?

Second: all spaces after NL before first nonblack char
but no more then current indentation are ignored, example:

New:

def f():
    """
    This is docstring,
    mama-mama,
  apple, banana
     """

is equivalent of old:

def f():
    """This is docstring,
mama-mama,
apple, banana
"""

Patch enabled if PyPARSE_STRIPPED_STRINGS defined. I
suggest you to apply patch but undefine
PyPARSE_STRIPPED_STRINGS until python-4 ;-)

I am sure, that this semantics is right, as
alternative, I suggest adding new modifier 'i' to
strings, like 'u' and 'r', for inst. i'iddqd'.

P. S. AFAIU, editing of parsermodule.c needed.

P. P. S. I am sorry, my English suck :-(


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-07-09 10:13

Message:
Logged In: YES 
user_id=21627

In that case,I think your proposed change will be highly
debated. That means you will have to write a PEP first if
you want to see it implemented (even if it is only an option).

----------------------------------------------------------------------

Comment By: Stepan Koltsov (yozh)
Date: 2002-07-08 18:06

Message:
Logged In: YES 
user_id=247706

I think the first part is still needed since
1. In r"""\
lalala
""" backslash doesn't escape NL
2. I think it looks better.

About second part:
1. Additional library routines make program text less readable.
2. They cannot know what indentation in spaces was where
string constant appeared.



----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-07-08 17:48

Message:
Logged In: YES 
user_id=21627

The first part of your patch is not needed, you can just as
fine write

"""\
la-la-la
"""

to escape the first newline.

The second patch is probably not needed either, since you
can easily write library routines that deal with that kind
of stripping. In fact, pydoc already does that transformation.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=578688&group_id=5470