Re: [Python-ideas] f-string "debug" conversion

2019-05-03 Thread Eric V. Smith
> On Oct 4, 2018, at 6:24 PM, Tim Peters wrote: > > [Tim] >> >> > Note that transforming >> > >> > {EXPR!d:FMT} >> > >> > into >> > >> > EXPR={repr(EXPR):FMT} >> > >> > is actually slightly more involved than transforming it into >> > >> > EXPR={EXPR:FMT} >> > >> > so I don't

Re: [Python-ideas] f-string "debug" conversion

2019-05-02 Thread Eric V. Smith
See https://bugs.python.org/issue36774. On 10/2/18 8:27 PM, Eric V. Smith wrote: This idea was proposed to me at the core sprints last month by Larry Hastings. I've discussed it with a few people, who seem generally positive about it, and we've tweaked it a little bit. I've spent some time imple

Re: [Python-ideas] f-string "debug" conversion

2018-11-16 Thread Rene Nejsum
+1 for this, I would use it all the time for debugging and tracing programs breakpoints and IDE’s can be nice, but my code is filled with lines like: logger.debug(f“transaction_id={transaction_id}, state={state}, amount={amount}, etc={etc}”) So yeah, well +10 actually :-) /rene ___

Re: [Python-ideas] f-string "debug" conversion

2018-10-04 Thread Tim Peters
[Tim] > > > Note that transforming > > > > {EXPR!d:FMT} > > > > into > > > > EXPR={repr(EXPR):FMT} > > > > is actually slightly more involved than transforming it into > > > > EXPR={EXPR:FMT} > > > > so I don't buy the argument that the original idea is simpler. More > > magical and le

Re: [Python-ideas] f-string "debug" conversion

2018-10-04 Thread Mikhail V
On Wed, Oct 3, 2018 at 3:28 AM Eric V. Smith wrote: > > 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 rep

Re: [Python-ideas] f-string "debug" conversion

2018-10-04 Thread Eric V. Smith
On 10/3/2018 8:47 PM, Tim Peters wrote: Note that transforming    {EXPR!d:FMT} into    EXPR={repr(EXPR):FMT} is actually slightly more involved than transforming it into    EXPR={EXPR:FMT} so I don't buy the argument that the original idea is simpler.  More magical and less useful, yes

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Nathaniel Smith
On Wed, Oct 3, 2018, 03:55 Eric V. Smith wrote: > > On 10/3/2018 1:40 AM, Nathaniel Smith wrote: > > I think the way I'd do it would be: > > > > Step 1: Take the current "lnotab" that lets us map bytecode offsets -> > > line numbers, and extend it with more detailed information, so that we > > can

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Tim Peters
[Guido] > Gah! You are overthinking it. This idea is only worth it if it's dead > simple, and the version that Eric posted to start this thread, where !d > uses the repr() of the expression, is the only one simple enough to bother > implementing. > In that case, I have no real use for it, for rea

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Guido van Rossum
Gah! You are overthinking it. This idea is only worth it if it's dead simple, and the version that Eric posted to start this thread, where !d uses the repr() of the expression, is the only one simple enough to bother implementing. -- --Guido van Rossum (python.org/~guido)

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Tim Peters
[Tim] > >> But what if >> > >> {EXPR!d:FMT} > >> > >> acted like the current > >> > >> EXPR={EXPR:FMT} > >> > >> ? I'd find _that_ useful often. For example, when displaying floats, > >> where the repr is almost never what I want to see. > >> ... [Eric V. Smith ] > After giv

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 7:07 AM, Eric V. Smith wrote: On 10/3/2018 12:23 AM, Tim Peters wrote: [Eric V. Smith mailto:e...@trueblade.com>>]     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 tex

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Ivan Levkivskyi
On Wed, 3 Oct 2018 at 11:45, Eric V. Smith wrote: > On 10/3/2018 3:54 AM, Steven D'Aprano wrote: > > On Tue, Oct 02, 2018 at 08:27:03PM -0400, Eric V. Smith wrote: > > > >> Here’s the idea: for f-strings, we add a !d conversion operator, which > >> is superficially similar to !s, !r, and !a. The

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 12:23 AM, Tim Peters wrote: [Eric V. Smith mailto:e...@trueblade.com>>] 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

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 1:40 AM, Nathaniel Smith wrote: On Tue, Oct 2, 2018 at 8:44 PM, David Teresi > 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() e

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
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 superfi

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 3:54 AM, Steven D'Aprano wrote: On Tue, Oct 02, 2018 at 08:27:03PM -0400, Eric V. Smith wrote: 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!

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Steven D'Aprano
On Wed, Oct 03, 2018 at 10:48:31AM +0200, Anders Hovmöller wrote: > > >> and much more readable. > > > > So you say. > > > > To me that looks like a regular function call, which calls an ordinary > > function "debug" and takes a simple keyword argument next with value > > "value+1". > > That

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Chris Angelico
On Wed, Oct 3, 2018 at 7:30 PM Jonathan Fine wrote: > 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. A

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Anders Hovmöller
> The present discussion thread is spreading into other areas, such as > what constitutes the Python language specification. I let myself get side tracked. This will be my last mail discussing that off topic thread. Sorry about that. > I'd like to > contribute to a broader discussion, of how w

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Jonathan Fine
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 mean

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Nicolas Rolin
As a user I would be really pleased with the change proposed, as I use extensively use f-string in my logging (the fact that I have to evaluate the string whatever the logger level is is not a performance hit for my application), and usually the most readable logging format is something akin to f"i

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Chris Angelico
On Wed, Oct 3, 2018 at 7:09 PM Anders Hovmöller wrote: > > > >> I don't really think accidents of implementation are different from hard > >> requirements in Python, as it applies to alternative implementations. In > >> practice if it deviates from CPython then it's broken. There is no > >> lan

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Anders Hovmöller
>> I don't really think accidents of implementation are different from hard >> requirements in Python, as it applies to alternative implementations. In >> practice if it deviates from CPython then it's broken. There is no language >> spec, there is only CPython. This has been the experience an

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Chris Angelico
On Wed, Oct 3, 2018 at 6:49 PM Anders Hovmöller wrote: > > I don't really think accidents of implementation are different from hard > requirements in Python, as it applies to alternative implementations. In > practice if it deviates from CPython then it's broken. There is no language > spec, th

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Anders Hovmöller
>> and much more readable. > > So you say. > > To me that looks like a regular function call, which calls an ordinary > function "debug" and takes a simple keyword argument next with value > "value+1". That was what it was. That was not intended to be about magic, that was the normal case w

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Chris Angelico
On Wed, Oct 3, 2018 at 5:54 PM Steven D'Aprano 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!")=

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Chris Angelico
On Wed, Oct 3, 2018 at 6:06 PM Steven D'Aprano wrote: > > On Wed, Oct 03, 2018 at 06:57:19AM +0200, Anders Hovmöller wrote: > > > debug(next=value+1) > > > > Still shorter than the proposed syntax > > Are we trying to emulate Perl now? *wink* > > > > and much more readable. > > So you say. > > To

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Steven D'Aprano
On Wed, Oct 03, 2018 at 06:57:19AM +0200, Anders Hovmöller wrote: > debug(next=value+1) > > Still shorter than the proposed syntax Are we trying to emulate Perl now? *wink* > and much more readable. So you say. To me that looks like a regular function call, which calls an ordinary functio

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Anders Hovmöller
>> 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!), > > I SO WANT THIS AS A GENERAL FEATURE, not just for f-strings, it hurts. > > Actually what I

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Steven D'Aprano
On Tue, Oct 02, 2018 at 08:27:03PM -0400, Eric V. Smith wrote: > 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!), I SO WANT THIS AS A GENERAL FEATURE,

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Nathaniel Smith
On Tue, Oct 2, 2018 at 8:44 PM, David Teresi 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. > > I also don't see the use case

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Anders Hovmöller
>> debug(=value, =another) > > What if it's not a simple name, though? The OP gave this (somewhat > simplistic, but indicative) example: > > print(f'next: {value+1!d}') debug(next=value+1) Still shorter than the proposed syntax and much more readable. If you do this a lot you’d probably call

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Tim Peters
[Eric V. Smith ] > 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. ..

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Chris Angelico
On Wed, Oct 3, 2018 at 2:11 PM Anders Hovmöller wrote: > > > > This would be used in debugging print statements, that currently end up > > looking like: > > > > print(f'value={value!r}') > > > > and would now be: > > > > print(f'{value!d}') > > It seems to me that a short form for keyword argumen

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Anders Hovmöller
> This would be used in debugging print statements, that currently end up > looking like: > > print(f'value={value!r}') > > and would now be: > > print(f'{value!d}') It seems to me that a short form for keyword arguments would improve this situation too. So instead of your suggestion one cou

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Chris Angelico
On Wed, Oct 3, 2018 at 1:45 PM David Teresi 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

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread David Teresi
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. I also don't see the use case of it being within an f-string, because I've never had to inte

[Python-ideas] f-string "debug" conversion

2018-10-02 Thread Eric V. Smith
This idea was proposed to me at the core sprints last month by Larry Hastings. I've discussed it with a few people, who seem generally positive about it, and we've tweaked it a little bit. I've spent some time implementing it, and I think it's doable. I thought I'd post it here for any addition