RFC PEP candidate: q'<delim>'quoted<delim> ?

Bengt Richter bokr at oz.net
Thu Mar 7 19:09:45 EST 2002


On Thu, 7 Mar 2002 08:09:52 -0600, "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote:

>Ugly.  You state that code like this:
>
>def somefunc():
>    astring = """this is the first line
>this is the second"""
>
>... is ugly.  Fine, but IMHO so is the proposed syntax.
>
>Recall always that the charm of Python is it's simplicity.  Even with the
>new language features added in 2.1 and 2.2, a "bear of little brain" can
>remember all the rules more or less at the same time.
>
Well, I think the charm is that one may use a very lean and clean subset of
the full set of features, but that need not imply that the full set must be limited.

Python already has plenty to boggle a "bear of little brain" in meta-classes
etc., so I don't think a feature that can safely be ignored should be criticized
on the basis of its taxing little bears' brains ;-)

>I am against pasting and patching one after another new language construct,
>syntax sweetener, etc. to Python because it detracts from that core
>simplicity
>each and every time.
>
I really agree. But I think the ability to __quote__ arbitrary raw text in source
is a __missing capability__. It's not something you can already do, that I'm just
proposing a sugar coating for. NB: I'm not saying you can't __define__ arbitrary string
content by writing suitable escape sequences etc. That's not the problem. The problem is
safely delimiting arbitrary __existing__ text __within__ a source file, without changing
it and without having to inspect it or make iffy assumptions about its content.

I think, e.g., that "for i in 5: ..." is *more* sugary, because you already have the
ability to do it with "for i in xrange(5): ..."

>This is why I am against incorporating the "$varname" interpolation
>operator.
>At least, IMHO it is not ugly.
>
But things like this you can often build using classes and subclassing. I would rather
extend the building capability (as has been done greatly with 2.2) than add pre-built gizmos.

>There seem to be a never-ending stream of new language feature proposals.
>Praise Guido they don't all get incorporated!
>
Agreed.
>(Don't take this personally.  I've had my share of similar ideas; we all
>think we are like Guido and can improve the language.  Learning to trust his
>language-design skills was hard, but rewarding.)
Well, once this has boiled down to a clear proposal, I'd like to hear his pronouncement.
Thus far, I don't seem to have succeeded in communicating the fact that Python can't
do now what it could using some implementation of this idea. It's not a new idea. It exists
in other contexts, so it's not a personal pet invention. It's a matter of whether Guido
will think the base functionality is desirable. If he does, he'll likely think of better
syntax for it. I would guess he invented triple quotes as an easy and convenient way to
deal with quoting a mix of single quotes. This just takes the next step, recognizing
that another fixed sequence (or two) of characters as delimiters will not do it.

Regards,
Bengt Richter



More information about the Python-list mailing list