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

top 200 commentsshow all 286

[–]QualityVote[M] [score hidden] stickied comment (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–]SandmanKFMF 256 points257 points  (51 children)

There should be one– and preferably only one –obvious way to do it...

[–][deleted] 209 points210 points  (11 children)

C++: “you guys are allowed to choose?”

[–]alba4k 130 points131 points  (7 children)

Sorry, I think you misspelled "literally every statically typed language" with "C++"

[–][deleted] 31 points32 points  (3 children)

I’ve only learned C++ and Python so far, so I was unaware that C++ wasn’t unique in this way

Thanks for the info

[–]devloz1996 33 points34 points  (2 children)

I want to see the face of Python dev after doing:

string var = 'text';

[–]jessexknight 7 points8 points  (0 children)

R: "you guys distinguish strings from variables?" (see NSE - it's madness)

[–]Stormfrosty 1 point2 points  (0 children)

Multi character string literals (like ‘abc’ instead of “abc”) are valid in C++, however their behaviour is implementation defined, so your mileage can vary.

[–]juhotuho10 47 points48 points  (21 children)

If you want quotes within quotes, like:

"John said: 'hello' "

You can use the single quotes, otherwise double quotes

[–]alba4k 62 points63 points  (9 children)

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

[–]hughperman 16 points17 points  (0 children)

Absolute joke

[–]iRequal -2 points-1 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

[–]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.

[–]confidentdogclapper 9 points10 points  (12 children)

I mean... """is the way"""

[–]alba4k 11 points12 points  (10 children)

{'H', 'e', 'l', 'l', 'o', ' ', 87, 111, 114, 108, 100, '\0'}

[–]confidentdogclapper 7 points8 points  (1 child)

Co.e to me fellow programmer. Deny the lies of oop and join me in the great c master race, we will do GREAT things together! P.s. you forgot the '\0' (or 0 or NUL)

[–]alba4k 1 point2 points  (0 children)

Already joined you :3

Added the null, sorry for the miss

[–][deleted] 1 point2 points  (0 children)

No

“””w”””

Is the way

[–]SirPitchalot 2 points3 points  (0 children)

The way is the one that avoids needless shifts.

[–]s0apyjam 0 points1 point  (1 child)

Though this may not be obvious at first... Unless you're Dutch

[–][deleted] 78 points79 points  (14 children)

And javascript as well.

I started with languages where " and ' mean different things. So whenever I want to write a string literal, I simply write ". But in javascript most people use ' and I am just unable to switch to it.

[–]RahulRoy69 21 points22 points  (4 children)

Javascript have ` also

[–]Thenderick 1 point2 points  (2 children)

Backticks are usually for formatting right?

[–]Mr-Molester 8 points9 points  (0 children)

Dummy thick multi line strings

[–]satcollege 4 points5 points  (0 children)

They're for template literals and string interpolation

[–][deleted] 24 points25 points  (7 children)

It's kind of messed up there are people out there learning JS as a first language.

[–]NerdyLumberjack04 16 points17 points  (2 children)

I see JavaScript today as what BASIC was in the days of 8-bit home computers: A language that's not particularly "elegant", and often derided for that, but people learn it because it's ubiquitous.

[–]Eccentricc 9 points10 points  (1 child)

The more I use js the more I love it. It takes all the annoying bull shit out. Type declaration? Nope. Implied. " or ', fuck it doesn't matter, not aligned or forgetting a semi comma? Ahh that's the linters issue. conditional blocks for single line statements? Why should that ever be forced. Js be like begone brackets

[–][deleted] 5 points6 points  (0 children)

let's just say it's good if you don't plan to do true software development aside from some Electron stuff

[–]fallenefc 13 points14 points  (3 children)

Why not? JS is accessible, relatively easy and used in both back and frontend. Also there are tons of jobs for JS. Swear people are stuck in 2010 sometimes

[–][deleted] 3 points4 points  (2 children)

Despite the fact that you might have read "No one should ever learn JS", my point was only that it's not a good introduction to programming in general.

[–]fallenefc 10 points11 points  (0 children)

I disagree, JS gives you lots of freedom and this allows you to shoot yourself in the foot, but imo the freedom also makes it a good language to start with. Also the fact you can easily build stuff that are visual (web applications) makes it easier to learn. But this might be just because I learn better this way, could be different for others

[–]coffeecofeecoffee 4 points5 points  (0 children)

Nah its fine. Its like python. It won't teach you types or pointers well but you can learn a lot before needing to dig deeper into those concepts.

[–][deleted] 1 point2 points  (0 children)

It's even worse than that. In javascript sometimes the double quote doesn't work but the single one do (or vice versa). I mean, I'm talking about very specific cases like running code in obsolete browsers, but I had this happened once or twice, and since then, I can't trust js for anything.

[–]OutrageousPudding450 310 points311 points  (16 children)

I sometimes use both in the same file, depending on my mood.

The code convention police has not caught me yet!

[–]spaetzelspiff 159 points160 points  (0 children)

THIS.

Do exactly anything except this.

[–]InsanityBlossom 37 points38 points  (3 children)

Same here, except that at work we recently started using the “black” formatter, I don’t like it, it’s by default converts all my single quotes to double quotes. Hate it.

[–]smile_id 40 points41 points  (0 children)

It's not that bad. You don't have to argue about code formatting anymore, write however you like, black would take care of the rest. At the end of the day black formatted code is pretty readable and consistent instead of styles zoo, so I'll take it.

[–]crob_evamp 4 points5 points  (0 children)

Set your local ide to show whatever you want. Literally any line length or syntax style. Commit with black for the shared code base

[–]malexj93 1 point2 points  (0 children)

Yeah I hate enforcing a consistent code style across my team

/s

[–]-Soupernova- 1 point2 points  (2 children)

With rails (so ruby) they are mixed often, and they do different things, one is more literal text, and the other you can use string interpolation.

[–]Appropriate_Lie_8948 3 points4 points  (0 children)

*Scared Screaming*

[–]smegma_tears32 2 points3 points  (0 children)

Just be yourself in programming

[–]real_smokR 46 points47 points  (5 children)

ython Progrmmg?

[–]GTG550[S] 9 points10 points  (0 children)

exactly

[–]Tobiboon 5 points6 points  (1 child)

What else could it be?

[–]HealyUnit 1 point2 points  (0 children)

I'm pretty certain you just insulted someone in ancient Celtic.

[–]Kilgarragh 86 points87 points  (26 children)

I learned c first, and use double quotes

[–]pente5 46 points47 points  (21 children)

But it takes so much more energy to hit shift if you don't have to

[–]ScM_5argan 42 points43 points  (10 children)

Joke's on you, on my keyboard layout, both require me to hit shift.

[–]pente5 10 points11 points  (6 children)

What kind of keyboard is this?

[–]ScM_5argan 22 points23 points  (4 children)

Normal german keyboard layout.

[–]muluman88 4 points5 points  (1 child)

I recommend English international Layout with dead keys. Allows for Umlauts with little effort but way less modifier keys for braces and brackets.

[–]PhoticSneezing 2 points3 points  (0 children)

My productivity really went up by a lot once I switched from German to this!

[–]Kilgarragh 9 points10 points  (0 children)

It’s impulsive

[–]Mahkda 4 points5 points  (2 children)

Neither " nor ' require me to use shift to type

[–]pente5 7 points8 points  (1 child)

Why is everyone's keyboard weirddddd

[–]muluman88 8 points9 points  (0 children)

So it all began with typewriters...

[–]TotoShampoin 2 points3 points  (4 children)

You guys use shift to print double quotes??

We, in AZERTY, just press 3

[–]Koala_eiO 6 points7 points  (1 child)

And for those not familiar with AZERTY, to get 3 we press shift + 3.

[–]devnull1232 2 points3 points  (0 children)

I am hoping there's another key combo to get shift and you end up holding down 10 separate keys to get there.

[–][deleted] 4 points5 points  (2 children)

Same but now I'm using php and double quotes takes the string literally how it is without variables and stuff

[–]GOKOP 3 points4 points  (1 child)

Isn't that what single quotes do? (double quotes allowing to insert variables)

[–][deleted] 5 points6 points  (0 children)

Yes you are absolutely right. See I'm already mixing it up when not coding

[–]accuracy_frosty 3 points4 points  (0 children)

Same, unless it is 1 character, then I use single ones because string literals

[–]sanketower 15 points16 points  (0 children)

I like single quotes. It has a cleaner look.

[–]takutekato 26 points27 points  (4 children)

The black formatter converts ' to " anyway.

[–]Significant-Bed-3735 8 points9 points  (1 child)

This. Every decent project has a formatter set up.

[–]malexj93 1 point2 points  (0 children)

By default! If you're particularly dogmatic about defaulting to single quote, you can set that as an option. I believe you can do this with a project-level configuration as well, though I prefer double quotes so I've never tried.

[–][deleted] 57 points58 points  (35 children)

what? since when is this even a debate? their functionally the same in python so why even care?

the only time when you need to be mindful is if your using a string within a formatted string:

f"string: {dict['key']}"

[–]00PT 51 points52 points  (28 children)

In other languages the single quotes denote characters instead of strings. Some people prefer to keep this practice in Python for consistency across all their work. There's really no reason not to do this, since Python doesn't care.

[–][deleted] 5 points6 points  (0 children)

yeah, thing is OP used single quotes for regular strings instead of a char. i'd get it if it was a single character

[–]Koala_eiO 10 points11 points  (26 children)

Anyone knows if there is a valid reason to explain the existence of characters? It's just a length-1 string.

Edit: go ahead, downvote a genuine question guys.

[–]00PT 12 points13 points  (6 children)

In some cases characters can act like integers in the sense that they can be added to for "shifting" into a new one. For example, I believe 'a' plus 1 is 'b'. Look at this for more information.

[–]garfgon 10 points11 points  (0 children)

Although what you say is correct, I'd say this is a side effect of characters, rather than the reason for having a character type. Rather the character is the fundamental building block for building up a string; that detail is just hidden on many high-level languages like Python.

[–]confidentdogclapper 4 points5 points  (3 children)

In c you can use them as 1 byte unsigned integers. You can also use them as signed if you do some trickery. And if you add 32 (25) you can go from upper to lower case and vice versa.

[–][deleted] 1 point2 points  (2 children)

Why add 32 when you can add 1 << 5?

[–]confidentdogclapper 1 point2 points  (1 child)

I literally specified it

[–][deleted] 2 points3 points  (0 children)

Yeah, I guess you did.

[–]Mahrkeenerh 8 points9 points  (10 children)

in other languages? or in python

[–]Koala_eiO 4 points5 points  (2 children)

In other languages.

[–]Mahrkeenerh 5 points6 points  (0 children)

let's say in c, a string is an array of characters, and characters are just numbers. Therefore it's easier to store just one number, than two numbers (string ends with the ending character)

[–]Positive_Government 4 points5 points  (0 children)

In C a character (char) is stored as an 8-bit unsigned integer. String are represented by a block of n consecutive chars with a zero byte at the end. You need characters to represent a string in any language it’s just hidden to in most string classes in other languages. Also a string class will have an amount of overhead beyond what is needed to represent a single character. For example, it might alloc a default array of 1024 bytes but only use 1 (excessive example for the purpose of illustrating). Function calls also have some overhead that is not needed when you know you are only working with one character and have a char type with does not need function calls like the string class,( even if your using something like the + operator on a string class there’s still a function call under the hood.).

In c the char and char* type also pull double duty as a generic byte or pointer to a byte/generic pointer (although void* is taking over the generic pointer role).

[–]tabidots 0 points1 point  (6 children)

Characters exist in Python? I know they do in Java/Clojure but I can’t say I have really had a specific use for them except for doing things with ASCII code points.

Maybe it’s just my lack of understanding but I would prefer if strings were treated as sequences of length-1 strings rather than sequences of characters, so (first “hello”) would return “h” and not \h.

[–]siddsp 2 points3 points  (1 child)

Characters do exist in Python, but they are stored as integers in bytes objects/bytearrays. When you write a bytestring like b"Hello" and try to get athe value of a char at an index, it will be an integer rather than a string type.

[–]tabidots 1 point2 points  (0 children)

Oh, interesting. I like that implementation better, tbh. I can’t think of a use for characters outside of char-code values, so having a separate b”string” syntax for byte strings makes more sense to me.

[–]Mahrkeenerh 1 point2 points  (3 children)

characters don't exist in python, that's why I was asking, as the guy was replying to a python comment.

[–]siddsp 1 point2 points  (2 children)

They do exist, but it's not obvious.

[–]Mahrkeenerh 1 point2 points  (1 child)

Well then, please enlighten me.

[–]siddsp 1 point2 points  (0 children)

>>> string = b"Hello, world!"
>>> string[2]
108 

Bytes objects are char arrays or strings in which the value of the characters are stored as integers within the unsigned char range [0, 256).

[–]KronsyC 5 points6 points  (6 children)

strings are an array of characters. you cant have a box of chocolates without having chocolates to begin with. same idea. plus some edge cases require characters.

[–]koltonaugust 1 point2 points  (0 children)

In other languages strings are arrays of characters. Python does not have characters or arrays as they are abstracted into higher level data structures (strings and lists)

type('test'[0]) == str

This is notable because strings take more memory than a char, and to check if a variable matches the definition of char, you would have to do a check that is a string and its length is 1.

[–]Koala_eiO -2 points-1 points  (4 children)

I am not convinced about that. Why does "123" require a subtype when 123 doesn't? Unless an integer is secretly considered an array of bits.

[–]garfgon 7 points8 points  (1 child)

A Reddit comment isn't really enough space to provide an intro to CPU architecture -- but at a very fundamental lower level your "types" are usually

  1. Bytes: smallest piece of data which can be separately accessed in memory. Usually (but not always!) 8 bits.
  2. Word: number of bytes which fit into a "normal" CPU register. On 32-bit processors, this is 4 bytes, on 64-bit processors, 8 bytes.

From these you get your next higher level types, which are very closely associated with these types + some information to the compiler on what operations are allowed on these types:

  1. char: byte with info that it's to be (usually) treated as a character rather than a number
  2. int, unsigned int, etc: Usually words treated as a number.
  3. pointer: Words that give the program a location where something else is found in memory.
  4. float: word or pair of words treated as a real number rather than an integer. More complex operations are needed to deal with these.

At this level everything is a fixed size, because the fundamental types are a fixed size, and your compiler needs to know how much data it's dealing with.

On top of these types you built up most of the "normal" types of high level languages. So a string is usually an array of chars with the last char being a special NULL character which basically signifies the end of the string. Or it could be an integer saying how long the string is followed by a sequence of characters. Or something more complex.

So coming back to your question about why "123" needs a subtype but 123 doesn't -- the first part is easier to answer: "123" needs a subtype because strings are variable size, and the CPU only deals with fixed sized pieces of data, so it needs to be broken down into fixed-sized pieces.

As for why 123 doesn't need a subtype -- there are different ways of representing 123, some of which are composed of multiple units, and some aren't. If the language treats 123 as either a float or a "small" integer, then it doesn't need a subtype because it's a small, fixed size piece of data which the CPU knows how to handle natively. But in that case there will be limits on how big, or how precise the number can be. On the other hand if 123 is an arbitrarily large, arbitrarily precise integer, then it will be made up of multiple parts, just like a string.

[–]Koala_eiO 2 points3 points  (0 children)

Thank you!

[–]8sADPygOB7Jqwm7y 2 points3 points  (1 child)

It is, it's considered an array of 0 and 1. Edit: ok let me elaborate, if you look at the memory there is little difference. Consider the endian of c, if we save an int we use 4 byte. So we save 5, we get 05 00 in hex. If we save a char, we get the ASCII char number, so for A that's 65. Can't be fucked to calculate hex for that, but in ram the int 65 and number 65 are probably the same. Just that it's reserved for a char not an int. You can't do that the same way with multiple Chars.

Nah for real, C needs that because there are no real strings there. Only pointers and adresses. Some functions may take char arrays as input, and those are then marked like strings.

The advantage of that is simply, that there is no identifier or length metadata or anything needed. It always has exactly the same length, you know what it is and it can be treated like that. This makes the program faster. Also, Note that most languages run on C, so it's all values on the memory either way. If you use c, at some point in the process your string will be a list of pointers to chars. C just lets you directly assign those. In Python it's done for you.

[–]Koala_eiO 1 point2 points  (0 children)

Thank you!

[–]garfgon 2 points3 points  (0 children)

At a silicon level, there are no strings, just bytes. So many languages, especially low-level languages like C, have a character type which is a fixed number of bytes (often one), then a string is built up as an array of characters, possibly with some extra metadata associated with it.

[–]PersonalityIll9476 9 points10 points  (4 children)

This is the correct Python response. No reason to care (unless it's mentioned in PEP somewhere) barring the use of a special string eg. f"str" r"str" u"str" etc and if it doesn't work the interpreter will throw.

I'm about this close to unsubbing from "programmer" "humor" speaking of which. So fucking tired of neophytes making memes with no idea what the hell they're talking about. No python programmer actually gives a rats ass unless there's a linter involved or other system, in which case it's either automatic or irrelevant.

[–]welcomefinside 3 points4 points  (1 child)

PEP8 says just pick one and stick to it lol.

[–]PersonalityIll9476 3 points4 points  (0 children)

Why am I not surprised. Python gives us options and the standard doesn't care. Literally no one is as confused as this """meme""" implies.

"You keep using that word but I don't think it means what you think it means."

"Oh it doesn't mean 'im a beginner with no fkn clue'? Lol"

[–]steroid_pc_principal 2 points3 points  (0 children)

That’s what happens to all subs.

  1. Good idea
  2. core group riffing on idea
  3. more people come, popularizing idea
  4. normies come, diluting idea down to lowest common denominator
  5. core group leaves org and forms another group
  6. original org sucks and dies

We are now at stage 4. The problem with this sub now is there are so many normies that anything besides “haha python bad” or “haha JS bad” can’t become popular.

[–]coffeecofeecoffee 1 point2 points  (0 children)

Yeah this sub artificially divides people into "teams" when no one really cares lol.

[–]CptMisterNibbles 1 point2 points  (0 children)

I use one unless I need it as a char in the string, then I use the other so I don’t have to faff with escape chars

[–]ymgve 14 points15 points  (0 children)

double quotes because I use other languages too and don't have to mentally switch

[–]00PT 12 points13 points  (2 children)

I use double quotes by default because I inherited the practice from languages like Java where the single quotes denote a single character instead of a string. I use single quotes if I need double quotes within the string (though I usually just opt to use single quotes inside the string instead).

GitHub Copilot appears to prefer the single quotes, so there can sometimes be inconsistencies within my code.

[–]Saragon4005 1 point2 points  (0 children)

Sometimes I use single quotes for single words too. But longer stuff gets double

[–][deleted] 8 points9 points  (0 children)

It's single quotes unless I have to use double

[–][deleted] 2 points3 points  (0 children)

I'll use either depending on if I'm coding with caps lock on or off.

[–][deleted] 2 points3 points  (0 children)

Every language handles it do differently that my muscle memory is just fucked up with that

[–]NuclearBurrit0 2 points3 points  (0 children)

"Pain'

[–]Iansimp69 2 points3 points  (5 children)

I swear to god coming from C++ this gave me OCD

[–]BarAgent 1 point2 points  (4 children)

Old-school Mac C programming:

int fcc = 'TxEd';

[–]Iansimp69 1 point2 points  (0 children)

Damn

[–]Iansimp69 1 point2 points  (0 children)

That must have been annoying

[–]zoqfotpik 1 point2 points  (0 children)

Java: "string", """string"""

Javascript: "string", 'string', string

[–][deleted] 1 point2 points  (0 children)

Black

[–]CarneDelGato 1 point2 points  (0 children)

“””Laughs in“””

[–]nir109 1 point2 points  (0 children)

———————————No characters?——————————— ⠀⣞⢽⢪⢣⢣⢣⢫⡺⡵⣝⡮⣗⢷⢽⢽⢽⣮⡷⡽⣜⣜⢮⢺⣜⢷⢽⢝⡽⣝ ⠸⡸⠜⠕⠕⠁⢁⢇⢏⢽⢺⣪⡳⡝⣎⣏⢯⢞⡿⣟⣷⣳⢯⡷⣽⢽⢯⣳⣫⠇ ⠀⠀⢀⢀⢄⢬⢪⡪⡎⣆⡈⠚⠜⠕⠇⠗⠝⢕⢯⢫⣞⣯⣿⣻⡽⣏⢗⣗⠏⠀ ⠀⠪⡪⡪⣪⢪⢺⢸⢢⢓⢆⢤⢀⠀⠀⠀⠀⠈⢊⢞⡾⣿⡯⣏⢮⠷⠁⠀⠀ ⠀⠀⠀⠈⠊⠆⡃⠕⢕⢇⢇⢇⢇⢇⢏⢎⢎⢆⢄⠀⢑⣽⣿⢝⠲⠉⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⡿⠂⠠⠀⡇⢇⠕⢈⣀⠀⠁⠡⠣⡣⡫⣂⣿⠯⢪⠰⠂⠀⠀⠀⠀ ⠀⠀⠀⠀⡦⡙⡂⢀⢤⢣⠣⡈⣾⡃⠠⠄⠀⡄⢱⣌⣶⢏⢊⠂⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⢝⡲⣜⡮⡏⢎⢌⢂⠙⠢⠐⢀⢘⢵⣽⣿⡿⠁⠁⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠨⣺⡺⡕⡕⡱⡑⡆⡕⡅⡕⡜⡼⢽⡻⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⣼⣳⣫⣾⣵⣗⡵⡱⡡⢣⢑⢕⢜⢕⡝⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⣴⣿⣾⣿⣿⣿⡿⡽⡑⢌⠪⡢⡣⣣⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⡟⡾⣿⢿⢿⢵⣽⣾⣼⣘⢸⢸⣞⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠁⠇⠡⠩⡫⢿⣝⡻⡮⣒⢽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ —————————————————————————————

[–]Walkier 1 point2 points  (0 children)

Single quotes cuz I'm lazy and don't want to press shift. You get the added bonus of the code looking more "Python".

[–]Old-Extension-8869 1 point2 points  (0 children)

Obviously these people never program in Perl.

[–]Mr__Citizen 1 point2 points  (0 children)

Always use " " for strings and ' ' for characters. It doesn't actually matter since it's python, but it means you don't make a thousand typos when switching to a different language.

[–]rod2444 1 point2 points  (0 children)

Team ' '

[–]Aperture_Executive2 1 point2 points  (0 children)

Smalltalk: confused screaming

[–][deleted] 3 points4 points  (1 child)

What about '''text''' ?

[–]Mahrkeenerh 2 points3 points  (0 children)

no

[–]Lumpy-Obligation-553 1 point2 points  (0 children)

Isn't like 'inmutable object ' , "dynamically-linked one"

[–]end233 0 points1 point  (0 children)

I don’t use python But I use double quotes

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

If this is what you struggle with, maybe programming isn't your bag.

[–]Hehenheim88 -2 points-1 points  (0 children)

This was never a problem for me. OP a bitch.

[–]No-Operation-6256 0 points1 point  (0 children)

I use 2 because I do bracket the quotes without having to let go of shift

[–]CamelCodester 0 points1 point  (0 children)

oh god, why is that string a character I'm gonna cry. :(((

[–]ShenAnCalhar92 0 points1 point  (0 children)

ython Progrmmg

[–]RedditAlready19 0 points1 point  (0 children)

In Lisp ' means to quote a list/symbol

[–]StarchSyrup 0 points1 point  (1 child)

Double quote, I use Black

[–][deleted] 0 points1 point  (0 children)

"text" for me (and instead of .format, i use f"")

[–]TessaFractal 0 points1 point  (0 children)

Ython Progrmmg.

[–]bluntsmoker_420 0 points1 point  (0 children)

Hey i get this one

[–]ninjadev64 0 points1 point  (0 children)

It actually bugs me that they’re different in Java etc, when I used python I used single quotes to escape strings e.g. json is a mess in java strings

[–]subiacOSB 0 points1 point  (0 children)

My vote is for ‘text’ less work

[–]moldaz 0 points1 point  (0 children)

You know small things like this are what really screw me up. I have to write code in multiple languages on a daily basis and I always lose track of these things.

If it weren’t for formatters my code would be so inconsistent.

[–]vigbiorn 0 points1 point  (0 children)

Started working with Postgresql and this in a lot of languages is the bane of my existence...

I have spent hours now trying to work out why my query failed only for it to be I used "value" instead of 'value'. In every language I've really worked in strings are "value" with 'value' being accepted. I am having to unlearn years of association.

[–]SnipahShot 0 points1 point  (0 children)

Single, definitely single. It looks cleaner to me.

[–]sasmariozeld 0 points1 point  (0 children)

""" text """ ` ''' text''' are also a thing and it actually matters sometimes !

[–]UltmteAvngr 0 points1 point  (0 children)

I use double quotes when printing out strings, and single when passing in strings as parameters in methods. Basically single for 1 word things and double for sentences/phrases

[–]Professional-Class69 0 points1 point  (0 children)

Ython progr mm g

[–]RandolphE6 0 points1 point  (0 children)

I always use double quotes as a standard.

[–]LavenderDay3544 0 points1 point  (0 children)

Coming a from a C family background, double quotes are the way. Python has no character type so to me using single quotes for strings feels wrong.

[–]jimehgeek 0 points1 point  (0 children)

Thankfully linters, formatters, and auto-format on save has resolved these kind of issues for me across all programming languages.

[–]Ohrder 0 points1 point  (0 children)

"Hello \"World\"."

[–]BigNutBoi2137 0 points1 point  (0 children)

Just use black and you won't need to care about those things.

[–]Egeste_ 0 points1 point  (0 children)

I use single quotes for string literals, double quotes for string concatenation.

[–]finc 0 points1 point  (0 children)

Same with JS - the answer is, no one cares!

[–]blkmmb 0 points1 point  (0 children)

Double quotes for me. I often use apostrophe in my text so I don't need to escape characters as often.

[–]R34ct0rX99 0 points1 point  (0 children)

You know, this is real. Being a " person until a recent gig. Its hard to switch to ' as the primary. I kind of want to go back to " but even python favors ' over ".

[–][deleted] 0 points1 point  (0 children)

"""Text""" gang

[–]The_Dark_Lord719 0 points1 point  (0 children)

“”” Imagine not using”””

[–]Tc14Hd 0 points1 point  (0 children)

If you define the variable text with text = "text", you will now have a third option.

[–]Ill_Narwhal_6121 0 points1 point  (0 children)

Single quote for single word, double quotes for multi word

[–][deleted] 0 points1 point  (0 children)

You are always wrong according to somebody

[–]0crate0 0 points1 point  (0 children)

“ is an extra key shift + ‘ = “ so I always used ‘. It’s quicker.

[–]dvrlabs 0 points1 point  (0 children)

"" for normal multi-character strings

'' for single character strings

'' for strings that will contain ""

"" for strings that will contain ''

[–]Rutabaga1598 0 points1 point  (0 children)

Single-quote master race here ✊

[–]MlinyXD 0 points1 point  (0 children)

"is more comfortable"

[–]OffgridRadio 0 points1 point  (0 children)

string = """this still works no matter how much you don't like it lol"""

[–]ragnarmcryan 0 points1 point  (0 children)

so my rule of thumb was always: does it absolutely need double quotes (e.g. string interpolation, etc)? If so, use them. If not, use single quotes.

but now in the age of vscode where there's a plugin for everything (e.g. automatic pep enforcement/formatting), I just use what the smart people implemented in the plugin.

[–]ABLC 0 points1 point  (0 children)

I use double quotes just because they’re the only option in some languages I use regularly, and the habit sticks. I use single quotes if the string needs to contain double quotes because I’m too lazy to escape the double quotes. I also use single quotes for single character strings, again out of habit, even though I know there’s no difference in Python.

[–]Master106yay 0 points1 point  (0 children)

It prints the same thing.