Py-dea: Streamline string literals now!
Dan Sommers
dan at tombstonezero.net
Wed Dec 28 20:44:18 EST 2011
On Wed, 28 Dec 2011 22:54:16 +0000, Steven D'Aprano wrote:
> On Wed, 28 Dec 2011 11:36:17 -0800, Rick Johnson wrote:
>
>> The point is people, we should be using string delimiters that are
>> ANYTHING besides " and '. Stop being a sheep and use your brain!
>
> "ANYTHING", hey?
>
> I propose we use ئ and ร as the opening and closing string delimiters.
> Problem solved!
Why stop at pre-determined, literal delimiters? That's way too easy on
the parser, whether that parser is a computer or a person.
__string_delimiter__ = Ω # magic syntax; no quotes needed
x = ΩhelloΩ
__string_delimiter__ = # # that first # isn't a comment marker
x = # this isn't a comment; it's part of the string
this is a multi-line string
#
__string_delimiter__ = '' # the delimiter is delimited by whitespace
# now I can have comments, again, too
x = ''"hello"'' # now x contains two double-quote characters
I'm sure that the implementation is trivial, and it's so much easier to
write strings that contain quotes (not to mention how easy it is to read
those strings back later).
--
Dan
More information about the Python-list
mailing list