[Python-ideas] Repr of lambda

Chris Barker chris.barker at noaa.gov
Thu Dec 21 01:57:39 EST 2017


On Mon, Dec 18, 2017 at 5:31 AM, Steve Barnes <gadgetsteve at live.co.uk>
wrote:

> I see it as showing that the information is already available to anybody
> who needs it so I question the usefulness of changing repr (for
> everybody)
> @dataclass
> class C:
>     a: "the a parameter" # field with no default
>     b: "another, different parameter" = 0.0 # field with a default
> .


well, digging into inspect and all that is definitely an advanced process
-- repr is for a quick look-see at the value of an object -- it would be
great to have one that was more informative.

and in theory, the "goal" is for eval(repr(obj)) to return an equivelent
object -- surely that would require showing the arguments and expression,
yes?

But is it bound to break somethign somewhere? given how, well, useless the
current lambda repr is, I can't imagine much breaking. But then I"ve been
known to lack imagination :-)

As for "proper" functions, I think it's pretty much off the table -- they
are simply too often complicated beasts with lots of parameters, lots of
code, multiple return possibilities, etc.

Is there a downside other than possible breakage? Performance issue, maybe?

And with regards to breakage -- anyone have code that would break (yeah, I
know, small sample, but if the answer is yes, lots, then we're done)

-Chris

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171220/7d53b889/attachment.html>


More information about the Python-ideas mailing list