[Python-ideas] f-string "debug" conversion
Eric V. Smith
eric at trueblade.com
Wed Oct 3 06:49:37 EDT 2018
On 10/3/2018 5:29 AM, Jonathan Fine wrote:
> Hi Eric
>
> Summary: This email is mainly about process. One discussion thread or
> several. I think the decision is yours.
>
> You wrote suggesting an enhancement for debugging:
>
>> Here’s the idea: for f-strings, we add a !d conversion operator, which
>> is superficially similar to !s, !r, and !a. The meaning of !d is:
>> produce the text of the expression (not its value!), followed by an
>> equal sign, followed by the repr of the value of the expression.
>
> You gave as one of several examples that given
> value = 10
> the expression
> f'{value!d}'
> evaluates to
> 'value=10'
> which can then be printed or logged.
>
> I thank you and Larry Hastings for coming up with and exploring this idea.
>
> Here's my personal opinion, which does not count for much. I like the
> output and ease of use. I have doubts about the implementation, and
> how it might work with other things. And also, I'd like the change to
> go through the PEP process.
I don't think a simple f-string feature needs a PEP. The implementation
is pretty simple, since the f-string parser already has access to the
string.
> The present discussion thread is spreading into other areas, such as
> what constitutes the Python language specification. I'd like to
> contribute to a broader discussion, of how we can improve the
> debugging experience. But I feel uncomfortable doing so in a
> discussion thread that started with your admirably clear focus.
>
> Briefly, Eric, would you like the general discussion of improving
> debugging to take place in this thread, or in another.
I think it would be more productive as a separate thread.
> Finally, if I may I thank you and Larry for your work on this
> important topic, and for starting this useful discussion.
Thanks. It's what we do!
Eric
More information about the Python-ideas
mailing list