2 ms·
I don't really understand what you mean. They're pointing out unintended consequences of allowing arbitrary string formats. You're linking to one you call "bett
by UnoriginalGuy 10y ago
I don't really understand what you mean. They're pointing out unintended consequences of allowing arbitrary string formats. You're linking to one you call "better" which would allow even more powerful misuse of arbitrary string formats.
And while Scala's string formatting looks cool, it hardly seems like your reply applies to the topic/thread. In fact ironically it seems to point out that this would be an even bigger issue in Scala.
- merb 10y ago> be an even bigger issue in Scala. not with string interpolation in scala. it only works on compile time so it's not possible to actually take user input strings (without runtime reflection of course) > it hardly seems like your reply applies to the topic/thread yes string interpolation (scala) has less todo with it. it can't be compared to the python one.
- kazinator 10y agoWhat the Python code is doing is arguably a form of run-time reflection. Format strings contain embedded variables and expression, and the format function evaluates them: hence reflection. Format strings occurring as literals in Python source could be treated at compile time, like in Scala.
- icebraining 10y agoPython's string interpolation only works on compile time as well¹, this isn't interpolation, it's a runtime method in the string class, which Scala also has, in fact, with the same name (.format). ¹ (compilation in CPython generally occurs during initialization of the execution, though you can pre-compile files manually)
- merb 10y agothanks for correcting me, actually my statement is not wrong that it has nothing to do with `.format` I was just mistaken about the python code, I tought it means the new stuff (i.e. interpolation), but I actually skipped the first code snippet.