Python String Sucks

By Xah Lee. Date: . Last updated: .

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 Idiosy

first, it has both APOSTROPHE and QUOTATION MARK char as equivalent delimiters, for its so called "short string" fuck. And this python short-string fuck, 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 one idiotic fuck.

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.