Raw string statement (proposal)

Chris Angelico rosuav at gmail.com
Sat May 26 15:21:38 EDT 2018


On Sun, May 27, 2018 at 5:13 AM, Mikhail V <mikhailwas at gmail.com> wrote:
> On Sat, May 26, 2018 at 7:10 PM, Steven D'Aprano

>>     temp = >>| Mikhail's syntax for {65290} is {65290}
>> Can you see the problem yet? How does your collapse function f()
>> distinguish between the escape code {65290} and the literal string
>> {65290}?
>
> Look, there is no any problem here. You can choose
> whatever YOU want to write "{" and "}". e.g. I'd pick {<} {>}.
>
>     temp = >>| Mikhail's syntax for {65290} is {<}65290{>}

Whatever notation you pick, you need some way to represent it
literally. Don't you see? All you're doing is dodging the issue by
making your literal syntax more and more complicated.

> I just show you that syntax allows you not only input TEXT
> without any manipulations, but also it allows to solve any task related
> to custom presentation - in this case you want work with
> ordinals for example. And you may end up with a scheme which
> reads way better than your cryptic example.

How about a simple notation that bases everything on a single typable
character like REVERSE SOLIDUS?

> I'll also ask you a question  -
> Which such non-text codes you may need to
> generate C code? Python code? HTML code?

What do you mean?

>> And we've gone from a single string literal, which is an expression that
>> can be used anywhere, to a statement that cannot be used in expressions.
>
> Ok show me your suggestion for a raw string definition for expressions
> (no modifications to source text and no usage of invisible control chars).

Ahh but "no modifications to source text" was YOUR rule, not ours.
Most of us are perfectly happy for string literals to be spelled with
quotes around them and a straight-forward system of escapes.

Or if we want NO modifications whatsoever, then we use another very
standard way of delimiting the contents: put it in a separate file and
then read that in. Oh wow, look at that, we can just put what we like
and it doesn't break anything!

I'm done. Argue with brick walls for the rest of eternity if you like.

ChrisA



More information about the Python-list mailing list