On Sat, Dec 1, 2018 at 10:18 AM Morten W. Petersen <morp...@gmail.com> wrote: > > On Fri, Nov 30, 2018 at 7:25 PM Dan Sommers < > 2qdxy4rzwzuui...@potatochowder.com> wrote: > > > On 11/30/18 12:00 PM, Morten W. Petersen wrote: > > > > > I guess syntax could be added, so that > > > > > > a, b, @c = some sequence > > > > > > would initialize a and b, and leave anything remaining in c. We could > > > then call this @ syntax "teh snek". > > > > Close. ;-) Try this: > > > > a, b, *c = [4, 5, 6, 7] > > > > > > I did not know that. Or maybe I read it somewhere and it was in the > subconscious. >
Be aware that this isn't the same as "leaving" everything in c. It will specifically gather everything in the rest of the iterable and put it all into a list in c. For this example, that wouldn't be a problem, but consider: >>> x = range(10) >>> a, b, *c = x >>> print(x) range(0, 10) >>> print(a, b, c) 0 1 [2, 3, 4, 5, 6, 7, 8, 9] But as long as you never dive into infinite iterators, it's going to be fine. ChrisA -- https://mail.python.org/mailman/listinfo/python-list