Re:New string formatting in Python
by mixmastamyk on Sunday January 03, 2016 @09:22PM
(#10833685)
That would mean the formattee would have to dig thru its surrounding namespace. This solution is more elegant, the string is transformed into the equivalent format call at compile time, making the implementation tiny.
[ Parent
| on HN ]
Python provides many ways to 'dig thru' the surrounding namespace. I find it ironic that do so is effortless in the language while at the same time is considered unpythonic. Which is it? Is the language itself unpythonic?
Re:New string formatting in Python
by mixmastamyk on Sunday January 03, 2016 @11:01PM
(#10833924)
Stack frame digging is discouraged yes, I'm ok with that.
Also, this alternative solution would not allow arbitrary expressions, which was a design goal.
Re:New string formatting in Python
by such_a_casual on Sunday January 03, 2016 @09:58PM
(#10833787)
Elegant for who?
Adding a new syntax that doesn't exist in any language.
vs.
Using sensible default parameters.
-----------------
An argument for why my suggestion would be bad: https://www.python.org/dev/peps/pep-0498/#no-use-of-globals-...
Re:New string formatting in Python
by mixmastamyk on Sunday January 03, 2016 @10:53PM
(#10833904)
> Adding a new syntax that doesn't exist in any language.
Not true, look into the new interpolation features in C#, Scala, JS, Swift, nim, etc.