On Wed, Oct 3, 2018 at 5:54 PM Steven D'Aprano <st...@pearwood.info> wrote:
> I'm not so sure that it only makes sense for named arguments. I think it
> works for arbitrary expressions too:
>
> f'{len("NOBODY expects the Spanish Inquisition!")!d}'
>
> ought to return
>
> 'len("NOBODY expects the Spanish Inquisition!")=39'
>
> which I can see being very useful in debugging expressions.

Absolutely! I can't imagine doing *hugely* complex expressions, but consider:

print(f"{request.args!d}")

Technically that's an "arbitrary expression" and is most definitely
not a named argument, but it's the sort of thing where you really do
want the tag to say "request.args" and not just "args" or anything
like that. Ideally, I'd like to be able to write this as:

dump(request.args)

and have it pick up both the string "request.args" and the value of
request.args, but the f-string variant is absolutely okay with me as a
partial solution.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to