foo.__call__.partial() solves most of the problem I think. בתאריך יום ג׳, 20 בספט' 2016, 12:43, מאת Michel Desmoulin < desmoulinmichel@gmail.com>:
(Sorry, answered to one person again. Reposting)
I like the bind() idea because it doesn't clutter the builtin namespace. It solves the import problem and feels very natural IMO.
The only issue is the name. In my mind, bind() convey the idea you are modifying the function it self, while partial() convey the idea you return new function.
It could also be written in C for performances.
Le 20/09/2016 à 10:22, אלעזר a écrit :
Yeah I did say it was a strawman :)
On Tue, Sep 20, 2016 at 11:17 AM Chris Angelico
mailto:rosuav@gmail.com> wrote: On Tue, Sep 20, 2016 at 6:09 PM, אלעזר
mailto:elazarg@gmail.com> wrote: > 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" () > Python has a rule that syntax shouldn't look like grit on Tim's screen. In this case, it looks like the *absence of* grit, which is even worse :) You're giving meaning to the abuttal of two tokens, the first of which must be callable but the second can be anything. And it creates the scary situation of giving valid-but-useless meaning to something all too common in Py2 code:
print "hello"
This would now create a function that, if called, would print "hello", but then abandons it without a second thought. So it'd work in 2.7, fail with an opaque error in 3.3, fail with a more informative error in 3.5, and silently do nothing in 3.7. No thank you! :)
ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org mailto:Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/