3 ms·
>That's not possible That statement is against my religious beliefs. Apparently we can stick an f in front of the string, but we can't have default values that
by such_a_casual 11y ago
>That's not possible
That statement is against my religious beliefs. Apparently we can stick an f in front of the string, but we can't have default values that work with locals()?
- mixmastamyk 11y agoThat 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.
- such_a_casual 11y agoElegant 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-or-locals https://www.python.org/dev/peps/pep-0498/#no-use-of-globals-...
- mixmastamyk 11y ago> 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.
- klibertp 11y ago> Adding a new syntax that doesn't exist in any language. Please, even JavaScript (ES6) got itself something similar; implicit string interpolation is not that rare.
- sitkack 11y agoPython 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?
- mixmastamyk 11y agoStack frame digging is discouraged yes, I'm ok with that. Also, this alternative solution would not allow arbitrary expressions, which was a design goal.