On 9/20/2015 8:37 AM, Nick Coghlan wrote: > On 19 September 2015 at 21:03, Eric V. Smith <eric at trueblade.com> wrote: >> Instead of calling __format__, I've changed the code generator to call >> format(expr1, spec1). As an optimization, I might add special opcodes to >> deal with this and string concatenation, but that's for another day (if >> ever). > > Does this mean overriding format at the module level or in builtins > will affect the way f-strings are evaluated at runtime? (I don't have > a strong preference one way or the other, but I think the PEP should > be explicit as to the expected behaviour rather than leaving it as > implementation defined). Yes, in the current implementation, if you mess with format(), str(), repr(), or ascii() you can break f-strings. The latter 3 are used to implement !s, !r, and !a. I have a plan to change this, by adding one or more opcodes to implement the formatting and string joining. I'll defer a decision on updating the PEP until I can establish the feasibility (and desirability) of that approach. Eric.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4