[Python-Dev] PEP-498: Literal String Formatting

Steven D'Aprano steve at pearwood.info
Tue Aug 11 04:17:42 CEST 2015


On Mon, Aug 10, 2015 at 09:23:15PM +0200, Guido van Rossum wrote:

[...]
> Anyway, this generalization from print() is why I want arbitrary
> expressions. Wouldn't it be silly if we introduced print() today and said
> "we don't really like to encourage printing complicated expressions, but
> maybe we can introduce them in a future version"... :-)

That's a straw-man argument. Nobody is arguing against allowing 
arbitrary expressions as arguments to functions.

If you want a fair analogy, how about the reluctance to allow arbitrary 
expressions as decorators?

@[spam, eggs, cheese][switch]
def function():
    ...


As far as I can see, the non-straw argument is that f-strings be limited 
to the same subset of expressions that format() accepts: name and 
attribute look-ups, and indexing.



-- 
Steve


More information about the Python-Dev mailing list