[Python-ideas] f-string "debug" conversion
Chris Angelico
rosuav at gmail.com
Tue Oct 2 23:49:37 EDT 2018
On Wed, Oct 3, 2018 at 1:45 PM David Teresi <dkteresi at gmail.com> wrote:
>
> print(f'{value!d}') is a lot of symbols and boilerplate to type out just for a debugging statement that will be deleted later. Especially now that breakpoint() exists, I can't really see myself using this.
>
What about when you want to log something without stopping the
program? TBH, I almost never use breakpoint.
> I also don't see the use case of it being within an f-string, because I've never had to interpolate a debug string within some other string or format it in a fancy way. You said it yourself, taking advantage of other f-string features isn't very useful in this case.
>
It's an f-string because f-strings are already compiler magic, so the
ability to display the expression as well as its result is more
logical and plausible.
> If other people can find a use for it, I'd suggest making it ita own function -- debug(value) or something similar.
>
As a normal function, that wouldn't be able to print out the text of
the expression, only the resulting value. If debug(value) could print
out "value: " and the value, then sure, but otherwise, it's not what
this is proposing.
ChrisA
More information about the Python-ideas
mailing list