Re: [Python-ideas] Repr of lambda

2017-12-18 Thread Serhiy Storchaka
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 Printing the return value requires adding a code or function attribute. Yes, this requires adding an optional constant code attribute. The return expression(s)

Re: [Python-ideas] Repr of lambda

2017-12-18 Thread Steve Barnes
On 18/12/2017 06:11, Ivan Pozdeev via Python-ideas wrote: > On 17.12.2017 22:20, Serhiy Storchaka wrote: >> Currently repr of doesn't contain much of information besides that it >> is a lambda. >> >> >>> lambda x: x**2 >> at 0x7f3479b74488> >> >> All lambdas have the same repr, different only b

Re: [Python-ideas] Repr of lambda

2017-12-18 Thread Steven D'Aprano
On Mon, Dec 18, 2017 at 07:54:17AM +, Steve Barnes wrote: > Isn't this exactly the sort of information already available via > inspect.getardspec, inspect.getsourcelines & inspect.getsource? [snip ipython interactive session showing that the answer is "Yes"] You answered your own question:

Re: [Python-ideas] Repr of lambda

2017-12-18 Thread Ivan Levkivskyi
Serhiy, I like the idea, but in typeshed we have an agreement to always show a default value by an ellipsis. For example, definition like this: def fun(x, y, z=0): return x + y + z can be represented like this fun(x, y, z=...) or if one has annotations in the definition, then fun(x: int,

Re: [Python-ideas] Repr of lambda

2017-12-18 Thread Steve Barnes
On 18/12/2017 11:43, Steven D'Aprano wrote: > On Mon, Dec 18, 2017 at 07:54:17AM +, Steve Barnes wrote: > >> Isn't this exactly the sort of information already available via >> inspect.getardspec, inspect.getsourcelines & inspect.getsource? > > [snip ipython interactive session showing that

[Python-ideas] Support floating-point values in collections.Counter

2017-12-18 Thread Joel Croteau
It would be useful in many scenarios for values in collections.Counter to be allowed to be floating point. I know that Counter nominally emulates a multiset, which would suggest only integer values, but in a more general sense, it could be an accumulator of either floating point or integer data. As