Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'languages.': 0.04; 'parameters': 0.04; 'syntax': 0.04; 'argument': 0.05; 'subject:PEP': 0.07; 'function,': 0.09; 'subject:skip:f 10': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'changes': 0.15; 'added.': 0.16; 'barrier': 0.16; 'c):': 0.16; 'creating,': 0.16; 'lambda': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'language': 0.16; 'wrote:': 0.18; 'written': 0.21; '(the': 0.22; 'programming': 0.22; 'aug': 0.22; 'proposed': 0.22; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'subject:like': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'suggested': 0.26; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'feature': 0.29; 'message-id:@mail.gmail.com': 0.30; '+0100,': 0.31; 'high.': 0.31; 'steven': 0.31; 'maybe': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'functions.': 0.36; 'entry': 0.36; 'example,': 0.37; 'too': 0.37; 'star': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'realize': 0.39; 'enough': 0.39; 'even': 0.60; 'most': 0.60; 'introduced': 0.61; 'new': 0.61; 'advanced': 0.63; 'kind': 0.63; 'myself': 0.63; 'needing': 0.65; 'special': 0.74; 'saw': 0.77; 'subject:this': 0.83; 'common,': 0.84; 'partial': 0.84; 'ugly,': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=mCC2w17CfSe3fktmYUZzWp3uopwiQlmiRdDZ/V8+GYc=; b=xyF7u6cOL3FCEY5DfaGVIkV3ZLAe2voyvLNizUlVX3raORCaIG613ubT+nMPhxr7me ARdzbzg59hYpPuo1GyaXoBeI0hRt5FCcnkxfwCORilcBocbmuL8E6XwZq8ar6v3kVuq4 zVU0/B5yXcWXEvlYCv/+NHHjIAo4d170XVxEDGRhOUOqJWpbjsTNdNZDJP6nAsrypOkM YWuwwPFHXEZp08OzESVlZ3+BSd7YmP4i0FgKf656FTyqLm5Sk0K+AXDsTomWG0xYL8iS yS1zgJ7Ka7tqFirxlGTBVbe0GCFDK056gDId0peMYdCV5s0Sg0dXKjGGJzoI96MXuwFa p2oQ== MIME-Version: 1.0 X-Received: by 10.224.66.74 with SMTP id m10mr2428459qai.12.1376987309279; Tue, 20 Aug 2013 01:28:29 -0700 (PDT) In-Reply-To: <521309d0$0$29885$c3e8da3$5496439d@news.astraweb.com> References: <521309d0$0$29885$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 20 Aug 2013 09:28:29 +0100 Subject: Re: Is this PEP-able? (syntax for functools.partial-like functionality) From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: "Steven D'Aprano" Content-Type: multipart/alternative; boundary=001a11c2c3386e12ae04e45cd7bd Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 96 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376987312 news.xs4all.nl 15991 [2001:888:2000:d::a6]:38599 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52726 --001a11c2c3386e12ae04e45cd7bd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 20 Aug 2013 07:22, "Steven D'Aprano" wrote: > > On Tue, 20 Aug 2013 00:49:16 +0100, F=E1bio Santos wrote: > > > I had an idea for a handy syntax which I thought of while designing a > > language for fun. This would be a syntax for creating, from a function, > > a function which is just like it but with some parameters pre-filled. > > The usage is much like functools.partials, and my proposed syntax is > > like this: > > > > def spam(a, b, c): > > ... > > > > spam_with_defaults =3D spam{1, 2} > > > Handy it may be, but why is this usage important enough to deserve new > syntax? The barrier to entry for new syntax is very high. For example, > Enums are a common, and standard, feature in many programming languages. > Enums will be introduced to Python in 3.4, but even they don't get > special syntax. > > > > -- > Steven 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. Maybe I saw this as common usage but it is really a special case. I see myself needing this kind of advanced partials _very_ often. --001a11c2c3386e12ae04e45cd7bd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On 20 Aug 2013 07:22, "Steven D'Aprano" <steve@pearwood.info> wrote:
>
> On Tue, 20 Aug 2013 00:49:16 +0100, F=E1bio Santos wrote:
>
> > I had an idea for a handy syntax which I thought of while designi= ng a
> > language for fun. This would be a syntax for creating, from a fun= ction,
> > a function which is just like it but with some parameters pre-fil= led.
> > The usage is much like functools.partials, and my proposed syntax= is
> > like this:
> >
> > def spam(a, b, c):
> > =A0 =A0 ...
> >
> > spam_with_defaults =3D spam{1, 2}
>
>
> Handy it may be, but why is this usage important enough to deserve new=
> syntax? The barrier to entry for new syntax is very high. For example,=
> Enums are a common, and standard, feature in many programming language= s.
> Enums will be introduced to Python in 3.4, but even they don't get=
> special syntax.
>
>
>
> --
> Steven

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 exam= ple, keyword-only argument syntax was added.

I suggested this because I thought it would be the most prac= tical way to create partial functions. Lambda is too verbose and kind of ug= ly, and its purpose is not to create partials, functools.partial does not a= llow argument "insertion" (the star thing) nor unpacking.

Maybe I saw this as common usage but it is really a special = case. I see myself needing this kind of advanced partials _very_ often.

--001a11c2c3386e12ae04e45cd7bd--