Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17023 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2011-12-12 03:44 -0500 |
| Last post | 2011-12-12 03:44 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 03:44 -0500
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-12-12 03:44 -0500 |
| Subject | Re: Verbose and flexible args and kwargs syntax |
| Message-ID | <mailman.3534.1323679511.27778.python-list@python.org> |
On 12/11/2011 6:44 PM, Eelco Hoogendoorn wrote: > Can you come up with some terse symbols that will be able to express all > of the below and dont make you wish you hadnt rather typed out the names? > > head, tuple(tail) = iterable > head, list(tail) = iterable > head, str(tail) = somestring > head, generator(tail) = mygenerator The above examples are seldom needed in Python because we have one general method to repeatedly split a sequence into head and tail. it = iter(iterable) # 'it' now represents the sequenced iterable head = next(it) # 'it' now represents the tail after removing the head In other words, next(it) encompasses all of your examples and many more. Because 'it' is mutated to represent the tail, it does not need to be rebound and therefore is not. Iterable unpacking with a *target for leftovers is an entirely different use case. -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web