[Python-ideas] A suggestion for Python 3 vs Python 2

אלעזר elazarg at gmail.com
Thu Nov 14 16:47:00 CET 2013


2013/11/14 Masklinn <masklinn at masklinn.net>:
>
> On 2013-11-14, at 16:05 , Steven D'Aprano <steve at pearwood.info> wrote:
>> Aside: am I the only one who wishes there was a functools.rpartial, that
>> binds from the right instead of the left?
>
> I’ve wanted this as well. Or the ability to somehow “fill holes”.
> Scala- or Clojure-type parse transforms are pretty neat for that
> (write the call with holes/placeholders, the call is deferred as a function
> taking arguments to fill the placeholders)
>
> Examples of Scala have already been provided, in Clojure it’s an explicit
> reader form:
>
>     #(foo 1 2 %)
>
> is equivalent (and expanded) to
>
>     (fn [arg] (foo 1 2 arg))

Ellipsis seems suitable for the latter:

sub5 = partial(sub, ..., 5)

(At the expense of giving up the abitily to pass ellipsis to partial functions).

Elazar


More information about the Python-ideas mailing list