On Sun, Nov 29, 2009 at 4:42 AM, inhahe <inh...@gmail.com> wrote:

> maybe that thing in python 3 that someone mentioned is the answer, but
> otherwise i always think Python should admit something like this:
>
> a, b, c, *d = list
>
> i.e. if list were [1,2,3,4,5], you'd get a=1, b=2, c=3, d=[4, 5]
>
> not that that solves the None problem, though i don't have any feature
> suggestions that would address that.
>
>
Maybe instead of Python working this way:

>>> a, b = xrange(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack

it should work this way:

>>> a, b = xrange(10)
>>> print a, b
0 1

and then they could include something in itertools that automatically fills
extras with None, like Peter Otten's implementation but without having to
pass it a value for the number of assignments, i.e.:
a, b, c = itertools.ifill(list)
with None being the default fill value, but if we wanted 1 to be, we could
do
a, b, c = itertools.ifill(list, 1)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to