> As Barry noted, this isn't as powerful as PEP 215 (er, was that the > right number? The earlier $interpolation one, anyway) because it > doesn't allow arbitrary expressions. That's intentional. Trying to put an expression parser in the interpolation code quickly leads to insanity. > I'd imagine a common use case > would be to shortcut an expression without binding it to a local > variable, > > "The length is ${length}".sub(length = len(someString)) > > In this case it would be handy to use the default environment overridden > by the new bindings, so you could do > > "The length of ${someString} is ${length}".sub(length = > len(someString)) > > But that could get messy real fast. The idiom could be > > "The length of ${someString} is ${length}".sub(someString = > someString, length = len(someString)) > > But that's ugly. I think you're simply trying to do too much in one line. Simple is better than complex. --Guido van Rossum (home page: http://www.python.org/~guido/)
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