Python String Sucks

By Xah Lee. Date: . Last updated: .

Python String Idiocy

python, the most idiotic programing language i have the displeasure to know.

in its string syntax,

It uses two different delimiters the APOSTROPHE and QUOTATION MARK, but both syntax have the same meaning. Both have special interpretation of backslash aka Python: String Escape Sequence.

and it adds triple quote, to both type of delimiter characters.

both syntax have the same meaning. The triple quote just means now they can include literal new line, i.e. multiple lines.

and it adds “prefix” of r for “raw”, to turn off special interpretation of backslash. e.g.

so, 2 possible string syntax now becomes 8.

extreme idiotic.

Python String Sucks

Python got the worst design for string. Let me explain.

# python string syntaxes

'APOSTROPHE'
"QUOTATION MARK"
"""triple QUOTATION MARK"""
'''triple APOSTROPHE'''

r'raw APOSTROPHE'
r"raw QUOTATION MARK"
r"""raw triple QUOTATION MARK"""
r'''raw triple APOSTROPHE'''

Issues of String Syntax Design

different string syntax in a programing language, is to solve the problem of:

Common Solution

Now, most languages solve these by:

Python String Syntax Design Idiocy

now, the way python tried to solve this, is:

Equivalent Delimiters Idiocy

first, it has both APOSTROPHE and QUOTATION MARK char as equivalent delimiters, for its so called "short string". And this python short-string, cannot have literal line return.

This is a bad design. Because having 2 syntax to do the same thing, and they are essentially the same, except if the string contains a APOSTROPHE or QUOTATION MARK, which in real life often contain both. So the python short-string syntax is idiotic.

Half-Solution of Triple Quote

Then, python the guido von rossum idiot, created triple quote, to solve the arbitrary big string problem. This is idiotic because, the text may contain python code involving triple quote, so you got a problem. it is inferior to the here-string,

Then, the guido von rossum idiot, created raw string concept, with the r prefix. Trying to solve the non-issue of whether escape sequence should be interpreted as literal. There is no mechanism to embed variable in string. (addendem, python added f-String to fix this problem. 〔see Python: f-String (Format, Template)〕 )

What guido should've done, is in python 3, make the APOSTROPHE delimeter as raw string and rid of the r raw string prefix.