Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!feeder.news-service.com!news2.euro.net!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'arguments': 0.05; 'infinite': 0.07; 'python': 0.08; 'arguments.': 0.09; 'subject:method': 0.09; 'syntax': 0.11; 'am,': 0.13; 'things.': 0.13; 'wrote:': 0.15; '(note:': 0.16; 'blah': 0.16; 'different,': 0.16; 'jumping': 0.16; 'received:192.168.1.40': 0.16; 'subject:function': 0.16; 'subject:syntax': 0.16; 'method.': 0.16; 'def': 0.16; 'slightly': 0.19; 'header:In-Reply-To:1': 0.22; 'encouraging': 0.23; 'interpreted': 0.23; 'in:': 0.25; 'keyword': 0.25; 'suggestion': 0.26; '(and': 0.27; 'pass': 0.28; 'correct': 0.29; 'construct': 0.30; 'does': 0.32; 'actually': 0.33; 'to:addr :python-list': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; "can't": 0.34; 'like:': 0.35; '(with': 0.35; 'subject:/': 0.36; 'idea': 0.36; 'error.': 0.36; 'anything': 0.37; 'open': 0.37; 'but': 0.37; 'could': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'skip:\xce 10': 0.38; 'something': 0.38; 'received:192.168.1': 0.39; 'ways': 0.39; 'help': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'your': 0.60; 'order': 0.62; 'received:62': 0.67; 'importantly,': 0.67; '8bit%:100': 0.70; 'objective': 0.77; 'from:addr:t': 0.84; 'idiomatic': 0.84; 'interesting,': 0.84; 'readability': 0.84; 'unreadable,': 0.84; 'points,': 0.91 Date: Mon, 18 Jul 2011 01:19:23 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Crazy what-if idea for function/method calling syntax References: In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310944762 news.xs4all.nl 23970 [2001:888:2000:d::a6]:49906 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9759 On 07/18/2011 12:54 AM, ΤΖΩΤΖΙΟΥ wrote: > Jumping in: > > What if a construct > > xx(*args1, **kwargs1)yy(*args2, **kwargs2) > > was interpreted as > > xxyy(*(args1+args2), **(kwargs1+kwargs2)) > > (Note: with **(kwargs1+kwargs2) I mean “put keyword arguments in the > order given”, since dicts can't be added) > > This construct is currently a syntax error. The intent of this idea is > to help improve legibility. > > Example: > def place_at(item, x, y): blah blah > could be called as > place(item)_at(x, y) Objective C does something similar. I don't actually know Objective C, but from what I remember from when I briefly read up on in (somebody please correct me), that call could, in Objective C, look something like: [ place:item atPositionX:x Y:y ] The idiomatic Python way for this is the following: def place(item, at): pass place(item, at=(x,y)) Your suggestion would open up an infinite number of different, mostly unreadable, ways to call a single method. This completely goes against the principle of encouraging there being only one way to do things. Multi-part method names (with fixed, non-optional, "split" points, if you know what I mean) are slightly interesting, but don't fit in, and, more importantly, don't add anything to the language: all the possible readability benefits are already provided (and trumped) by keyword arguments.