[Python-ideas] Make partial a built-in

אלעזר elazarg at gmail.com
Tue Sep 20 04:09:47 EDT 2016


On Tue, Sep 20, 2016 at 10:54 AM Chris Angelico <rosuav at gmail.com> wrote:

> On Tue, Sep 20, 2016 at 5:01 PM, אלעזר <elazarg at gmail.com> wrote:
> > But the foo() finds the function to call, so foo.bind() could be made to
> > find it too.
>
> class Demo:
>     def __init__(self):
>         self.bind = 42
>     def __call__(self):
>         print("I got called!")
>
> foo = Demo()
>
> You can most certainly call foo(), but foo.bind() will bite you.
>
> With a stand-alone function bind(foo), it can use protocols like __call__.
>
> I meant something like making it a "__bind__" (just a strawman suggestion)
and do the same lookup as foo() does, and using a (wrong)
functional-programming-inspired syntax

    foo 5 ()

Such a syntax will have the side benefit of allowing calling print in a
similar way to Python2, which people seem to love.

    print "hello" ()

This strawman proposal has many downsides I guess. My point being, this can
be made to work, but it's probably not worth it.

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160920/d1f54842/attachment.html>


More information about the Python-ideas mailing list