▲ 684 ▼ The Perfect Solution (programming.dev) submitted 2 years ago by JPDev@programming.dev to c/programmer_humor@programming.dev 77 comments fedilink hide all child comments
[–] Mastershelf@lemmy.one 11 points 2 years ago (6 children) TIL Python dictionaries allow trailing commas. permalink fedilink source hideshow 6 child comments replies: [–] GBU_28@lemm.ee 5 points 2 years ago (2 children) List permalink fedilink source parent hideshow 2 child comments replies: [–] dalegribble@beehaw.org 5 points 2 years ago (1 child) While there are not actually any trailing commas in the dictionaries present and you are correct to say the ones present are part of a list, you can also have trailing commas in Python dictionaries. OP might have researched “Python trailing commas” and learned that part. Trailing commas are fantastic to reduce changed lines in git diffs. Makes life much better. Same thing with leading commas in SQL queries. permalink fedilink source parent hideshow 1 child comment replies: [–] GBU_28@lemm.ee 2 points 2 years ago Yeh permalink fedilink source parent [–] Ephera@lemmy.ml 3 points 2 years ago (1 child) Yeah, I think, that's only really JSON which is so pedantic about it... permalink fedilink source parent hideshow 1 child comment replies: [–] owenfromcanada@lemmy.world 3 points 2 years ago Yeah... sweats nervously in C permalink fedilink source parent [–] renzev@lemmy.world 1 point 2 years ago Python is so great (half-sarcasm) that a trailing comma on its own constitutes a tuple (immutable list): mytuple = 4, assert len(mytuple) == 1 assert mytuple[0] == 4 permalink fedilink source parent
[–] GBU_28@lemm.ee 5 points 2 years ago (2 children) List permalink fedilink source parent hideshow 2 child comments replies: [–] dalegribble@beehaw.org 5 points 2 years ago (1 child) While there are not actually any trailing commas in the dictionaries present and you are correct to say the ones present are part of a list, you can also have trailing commas in Python dictionaries. OP might have researched “Python trailing commas” and learned that part. Trailing commas are fantastic to reduce changed lines in git diffs. Makes life much better. Same thing with leading commas in SQL queries. permalink fedilink source parent hideshow 1 child comment replies: [–] GBU_28@lemm.ee 2 points 2 years ago Yeh permalink fedilink source parent
[–] dalegribble@beehaw.org 5 points 2 years ago (1 child) While there are not actually any trailing commas in the dictionaries present and you are correct to say the ones present are part of a list, you can also have trailing commas in Python dictionaries. OP might have researched “Python trailing commas” and learned that part. Trailing commas are fantastic to reduce changed lines in git diffs. Makes life much better. Same thing with leading commas in SQL queries. permalink fedilink source parent hideshow 1 child comment replies: [–] GBU_28@lemm.ee 2 points 2 years ago Yeh permalink fedilink source parent
[–] Ephera@lemmy.ml 3 points 2 years ago (1 child) Yeah, I think, that's only really JSON which is so pedantic about it... permalink fedilink source parent hideshow 1 child comment replies: [–] owenfromcanada@lemmy.world 3 points 2 years ago Yeah... sweats nervously in C permalink fedilink source parent
[–] owenfromcanada@lemmy.world 3 points 2 years ago Yeah... sweats nervously in C permalink fedilink source parent
[–] renzev@lemmy.world 1 point 2 years ago Python is so great (half-sarcasm) that a trailing comma on its own constitutes a tuple (immutable list): mytuple = 4, assert len(mytuple) == 1 assert mytuple[0] == 4 permalink fedilink source parent