Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52733

Re: Is this PEP-able? (syntax for functools.partial-like functionality)

References <mailman.43.1376956165.19984.python-list@python.org> <521309d0$0$29885$c3e8da3$5496439d@news.astraweb.com> <CAA=1kxQiu_RNtM1uig6WGq8p9R0WJd4xEmwV-p31OvBCQ4CDSg@mail.gmail.com> <CALwzid=5c3V820oZf2hSJ0-SUWnaPQrgdYRk5+dnBy_YomO2nw@mail.gmail.com>
Date 2013-08-20 10:25 +0100
Subject Re: Is this PEP-able? (syntax for functools.partial-like functionality)
From Fábio Santos <fabiosantosart@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.56.1376990742.19984.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 20 Aug 2013 10:14, "Ian Kelly" <ian.g.kelly@gmail.com> wrote:
>
> On Tue, Aug 20, 2013 at 2:28 AM, Fábio Santos <fabiosantosart@gmail.com>
wrote:
> > I do realize that syntax in python is practically written in stone, but
I
> > have seen changes come by if they have good reasons. For example,
> > keyword-only argument syntax was added.
> >
> > I suggested this because I thought it would be the most practical way to
> > create partial functions. Lambda is too verbose and kind of ugly, and
its
> > purpose is not to create partials, functools.partial does not allow
argument
> > "insertion" (the star thing) nor unpacking.
>
> I think that if you're doing argument insertion, then your partial
> application is overly complex in the way that it modifies the original
> argspec.  You should be looking at it as a new function, not as a
> partial application that prevents you from easily supplying a doc
> string for it.  If you want to specify an arbitrary combination of
> arguments in your partial application, you can already do that using
> keyword arguments.  The exception would be if the function being
> partially applied takes a *args argument and you want to specify some
> of those arguments using partial without specifying earlier arguments.
>  That seems like an abuse of partial application to me.
>
> Tuple unpacking in function signatures was a feature in Python 2, and
> it was intentionally removed in Python 3, so this is very unlikely to
> happen.  See PEP 3113.  Besides which, the syntax you suggest for this
> is unintuitive.
>
>    spam_unpacking = spam{1, (*, *)}
>
> To me, this reads that spam_unpacking will take two positional
> arguments that will be packed into the second argument sent to spam
> (b), and that the third argument to spam (c) is not specified here.  I
> don't think that's what you intended.

No, that syntax was meant to take a tuple and break it into two arguments.
It does read terribly.

Anyway, good points were made and I have seen the light. I've changed my
mind. This is a bad idea.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Is this PEP-able? (syntax for functools.partial-like functionality) Fábio Santos <fabiosantosart@gmail.com> - 2013-08-20 00:49 +0100
  Re: Is this PEP-able? (syntax for functools.partial-like functionality) Steven D'Aprano <steve@pearwood.info> - 2013-08-20 06:16 +0000
    Re: Is this PEP-able? (syntax for functools.partial-like functionality) Fábio Santos <fabiosantosart@gmail.com> - 2013-08-20 09:28 +0100
    Re: Is this PEP-able? (syntax for functools.partial-like functionality) Ian Kelly <ian.g.kelly@gmail.com> - 2013-08-20 03:11 -0600
    Re: Is this PEP-able? (syntax for functools.partial-like functionality) Fábio Santos <fabiosantosart@gmail.com> - 2013-08-20 10:25 +0100

csiph-web