17.12.17 22:55, Terry Reedy пише:
What if include the signature and the expression of the lambda in its repr?

 >>> lambda x: x**2
<lambda x: x**2>

Printing the return value requires adding a code or function attribute.

Yes, this requires adding an optional constant code attribute.

The return expression(s), possibly None, would be just as useful for named functions.

In case of named functions the body is not an expression and usually is multiline.

But there is a problem with default values. Their reprs can be very long, especially in the following case with mutable default value:

I would not expect the representation to change; just use the expression.

This is a solution, thanks.

Maybe the placeholder should be always used instead of default values.

Do you mean 'a placeholder'?

Yes, sorry.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to