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

noreply@sourceforge.net noreply@sourceforge.net
Mon, 08 Jul 2002 08:48:00 -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-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