Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'argument': 0.05; 'abuse': 0.07; 'subject:PEP': 0.07; 'string': 0.09; 'arguments': 0.09; 'function,': 0.09; 'happen.': 0.09; 'modifies': 0.09; 'pep': 0.09; 'prevents': 0.09; 'subject:skip:f 10': 0.09; 'python': 0.11; 'suggest': 0.14; 'changes': 0.15; '*args': 0.16; '2:28': 0.16; 'added.': 0.16; 'intended.': 0.16; 'lambda': 0.16; 'positional': 0.16; 'specifying': 0.16; 'supplying': 0.16; 'tuple': 0.16; 'unlikely': 0.16; 'unpacking': 0.16; 'which,': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'written': 0.21; 'seems': 0.21; '(the': 0.22; 'aug': 0.22; 'specify': 0.24; 'subject:like': 0.24; 'earlier': 0.24; 'suggested': 0.26; 'second': 0.26; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'feature': 0.29; '(c)': 0.29; 'am,': 0.29; 'besides': 0.30; 'specified': 0.30; 'message- id:@mail.gmail.com': 0.30; 'doc': 0.31; 'third': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'combination': 0.36; 'functions.': 0.36; 'keyword': 0.36; 'doing': 0.36; 'should': 0.36; 'example,': 0.37; 'application': 0.37; 'too': 0.37; 'two': 0.37; 'easily': 0.37; 'being': 0.38; 'star': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; 'new': 0.61; "you're": 0.61; 'kind': 0.63; '20,': 0.68; 'reads': 0.68; 'subject:this': 0.83; 'partial': 0.84; 'partially': 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:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=9mzvWuCH+CFr7oAGvrvP7R0a1jUNJxFSN2+lHBzStGQ=; b=hpnx1W1ZhAd4R9oM0YJF/GXH/ySDn0AAWwdkG48jT0S0cBQBxQe6R4/yxWh0ifUOHW flwcFMMZ2mozW1hvd3+TkVbBykBMEmMChqRyZ/1/mQPqKWc6X7qo/ASzdZzt+oHL1yun J8Pqui0DfRsxBdh4VDCIS++SotqxacuEWAUyy2IBW3aUG0mV+VRk/f6Ip9gTnRasB+pc z0jJXKW/OOsUMD9+B8MKCmTwbREeT+eSWBnvJ4dgVJdgN2F7MeSB1wWwAHcwulmbIi1W f7X5FkaWSUnBJAWE3EVILTZ6/vTM6hUm0rbzhxZFxqwdb96E/WNnymEqfR4Xa/lmhT/s 6Big== X-Received: by 10.68.213.5 with SMTP id no5mr539133pbc.185.1376989941991; Tue, 20 Aug 2013 02:12:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <521309d0$0$29885$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Tue, 20 Aug 2013 03:11:41 -0600 Subject: Re: Is this PEP-able? (syntax for functools.partial-like functionality) To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376989951 news.xs4all.nl 15903 [2001:888:2000:d::a6]:56452 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52729 On Tue, Aug 20, 2013 at 2:28 AM, F=E1bio Santos = 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 argum= ent > "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 =3D 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.