5 ms·
Sigils have been standard in shells for decades. And sigils allow string interpolation to work; again, just like in normal unix shells. The python people decide
by dima55 8y ago
Sigils have been standard in shells for decades. And sigils allow string interpolation to work; again, just like in normal unix shells. The python people decided that sigils are a bad idea, so instead of being able to say "I have $n apples" (like you could in shells we've all been using forever!) I now need to say "I have {} apples".format(n). I know which one I prefer!
- sqrt17 8y agoJavascript has `I have ${n} apples`, or even `This is chapter ${i+1}.` In terms of interpolation, that's the variant that I like best.
- erik_seaberg 8y agoPython added https://www.python.org/dev/peps/pep-0498/ https://www.python.org/dev/peps/pep-0498/.
- snapdangle 8y agoPerl 6 does it without the sigil outside the bracket :) "I have {some-complex-calc($i)} frobitzes"
- jdhzzz 8y agoAlso in groovy. I too am a fan.
- vorg 8y agoUnlike Python's `"I have {} apples".format(n)` and various shells' `"I have $n apples"`, Javascript's and Apache Groovy's `"This is chapter ${i+1}"` mean the lexer must make a call to the parser when lexing the string contents -- this allows `"This is ${"chapter"} ${i+1}"` to parse. Don't know about Javascript, but this makes Groovy's parser unreadable, and stuck on a very old version of Antlr, i.e. 2 instead of 4 (the latest).