Hi Evan,
f-strings support a version of this. If you put an equals sign at the
end of the expression in your f-string (possibly with white space) then
the f-string will include both the expression itself and its value in
the result:
>>> a = 12; b = 13
>>> f'{a == b}'
'False'
Are you familiar with the f-string self-documentation operator in python
3.8?
https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging
With it you can say:
print(f"{a==b=}")
---
Ricky.
"I've never met a Kentucky man who wasn't either
On Tue, Nov 2, 2021 at 1:31 PM Evan Greenup via Python-ideas
wrote:
>
> It would be nice to add the following syntax sugar in Python "Print and Eval"
>
> like `ptev a == b` It is same as `statement = "a == b"; print(f"{statement} ?
> {eval(statement)}")`.
>
> It would super nice for debugging
It would be nice to add the following syntax sugar in Python "Print and Eval"
like `ptev a == b` It is same as `statement = "a == b"; print(f"{statement} ?
{eval(statement)}")`.
It would super nice for debugging and other research project.
___
On Mon, Nov 1, 2021 at 7:39 PM Evpok Padding wrote:
>
> I definitely agree with that sentiment, with beginners I don't even talk
> about function defaults at first, and when I do, it's when we have already
> have a talk about mutables so I can just say that you almost never want a
> mutable
On Mon, Nov 01, 2021 at 09:39:01AM +0100, Evpok Padding wrote:
> I don't look forward to having to add yet another side note about syntactic
> sugar that does not really add much value (it saves a few characters but
> it's less clear
This proposal is not about saving a few characters. We could
I definitely agree with that sentiment, with beginners I don't even talk
about function defaults at first, and when I do, it's when we have already
have a talk about mutables so I can just say that you almost never want a
mutable default but rather use None as a sentinel. It's not that hard and
it
On Mon, Nov 1, 2021 at 5:57 PM Guido van Rossum wrote:
>
> Agreed, class namespaces are weird. :-)
>
Ah yes, I forgot about class namespaces. I was thinking about
deliberately wonky namespaces where the ns dict has a __missing__
method or something, but inside a class, "b = b" actually has a
Agreed, class namespaces are weird. :-)
On Sun, Oct 31, 2021 at 23:38 Chris Angelico wrote:
> On Mon, Nov 1, 2021 at 5:15 PM Greg Ewing
> wrote:
> >
> > On 1/11/21 4:59 am, David Mertz, Ph.D. wrote:
> > > b = b
> >
> > I don't want to live in a universe where this could be anything
> >
On Mon, Nov 1, 2021 at 5:15 PM Greg Ewing wrote:
>
> On 1/11/21 4:59 am, David Mertz, Ph.D. wrote:
> > b = b
>
> I don't want to live in a universe where this could be anything
> other than a no-op in Python.
>
Be careful what you say: there are some technicalities. If you mean
that it
On 1/11/21 4:59 am, David Mertz, Ph.D. wrote:
b = b
I don't want to live in a universe where this could be anything
other than a no-op in Python.
--
Greg
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to
11 matches
Mail list logo