Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9759
| Date | 2011-07-18 01:19 +0200 |
|---|---|
| From | Thomas Jollans <t@jollybox.de> |
| Subject | Re: Crazy what-if idea for function/method calling syntax |
| References | <e3275985-7cb4-4144-8962-17f0ed4658be@l18g2000yql.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1194.1310944762.1164.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Crazy what-if idea for function/method calling syntax ΤΖΩΤΖΙΟΥ <tzotzioy@gmail.com> - 2011-07-17 15:54 -0700
Re: Crazy what-if idea for function/method calling syntax Thomas Jollans <t@jollybox.de> - 2011-07-18 01:19 +0200
Re: Crazy what-if idea for function/method calling syntax Cameron Simpson <cs@zip.com.au> - 2011-07-18 12:04 +1000
Re: Crazy what-if idea for function/method calling syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-17 21:29 -0600
Re: Crazy what-if idea for function/method calling syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-18 15:54 +1000
Re: Crazy what-if idea for function/method calling syntax Pierre Quentel <pierre.quentel@gmail.com> - 2011-07-18 13:34 -0700
csiph-web