[Python-ideas] Function composition (was no subject)

Ivan Levkivskyi levkivskyi at gmail.com
Thu May 7 20:01:14 CEST 2015


> On Thu, May 7, 2015 at 7:09 PM, Jo?o Santos <jmcs at jsantos.eu> wrote:
> > On Wed, 6 May 2015 at 16:51 Steven D'Aprano <steve at pearwood.info> wrote:
> >>
> >>
> >> I think that there are some questions that would need to be answered.
> >> For instance, given some composition:
> >>
> >>     f = math.sin @ (lambda x: x**2)
> >>
> >> what would f.__name__ return? What about str(f)?
> >
> >
> > Lambdas return '<lambda>' so maybe something like '<composed>'?
> > Then str(f) would be '<function <composed> at 0xffffffffffff>'.
>
> Would be nice to use "<sin @ <lambda>>", incorporating both names, but
> that could get unwieldy once you compose a bunch of functions.

Maybe it would be better to have '<function <composed> at 0xffffffffffff>'
for str(f) but 'sin @ <lambda>' for repr (f). So that one can have more
info and it would be closer to idealistic obj == eval (repr (obj)).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150507/a118efac/attachment.html>


More information about the Python-ideas mailing list