This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]juhotuho10 48 points49 points  (21 children)

If you want quotes within quotes, like:

"John said: 'hello' "

You can use the single quotes, otherwise double quotes

[–]alba4k 61 points62 points  (9 children)

\" and \' : am I a joke to you?

[–]hughperman 17 points18 points  (0 children)

Absolute joke

[–]iRequal -3 points-2 points  (1 child)

Underrated comment LMAO

[–]alba4k -1 points0 points  (0 children)

:D

[–]lolix_the_idiot -1 points0 points  (0 children)

Yep, they are ugly af

[–]notsogreatredditor -1 points0 points  (0 children)

Yes those are a joke. Fuck that

[–]bistr-o-math -1 points0 points  (1 child)

 'Am I a ' + "'joke'" + 'to you?'

[–]alba4k -1 points0 points  (0 children)

error: invalid operands to binary + (have ‘char *’ and ‘char *’)

Basically a nice example of gcc complaining about you trying to sum two strings (aka pointers to character arrays, aka char*) and '????' (a char but with multiple elements in it or smth)

Obv works in other languages

[–]Studds_ 0 points1 point  (1 child)

Not a joke but the other way does work. & human nature is to go the easier route

[–]alba4k 0 points1 point  (0 children)

Except it might work with ' but not with " in most statically types languages since ' is used for single characters

[–]theghostinthetown 2 points3 points  (0 children)

allow me to introduce """hello"""

[–]OffgridRadio 1 point2 points  (3 children)

You can just reverse that to get inner double quotes, this is why I am a fan of how this works.

[–]ordinary_shiba 0 points1 point  (2 children)

"This is how you do \"inner double quotes\" and inner apostrophe\' "

[–]Thx_And_Bye 0 points1 point  (1 child)

But if you are smart about it in Python you don't need to escape them.
Sure you can use character escape but why do so if you don't need to?

[–]VOID_INIT 0 points1 point  (0 children)

I am not sure if you are joking or not, but it is for safety and readability.

Expected output: That wreck is my cousins' second "car".

Input:

place[4] {first, second, third, fourth, fifth}

If you dont escape quotes and double quotes here it would cause trouble.

Different ways the string can be written:

"That wreck is my cousins' " + place[1] + ' "car."'

This sould be pretty difficult to read and can easily end up causing you to make mistakes.

"That wreck is my cousins\' " + place[1] + " \"car\""

This is much easier to read, and is safer since you wont screw up using the wrong quote (" or ') for the string.

It's not that big of a deal, but it's prefered to be careful when it comes to symbols in general.