On 06.03.2016 19:51, Tim Chase wrote:
So it looks like one needs to either
results = reversed(list(zip(...)))
or, more efficiently (doing it with one less duplication of the list)
results = list(zip(...))
results.reverse()
Nice idea. :) Unfortunately, I used it while drafting som
On 06.03.2016 19:53, Peter Otten wrote:
Sven R. Kunze wrote:
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
In Python 3 zip() can deal with infinite iterables -- what would you expect
from
r
On 2016-03-06 18:29, Sven R. Kunze wrote:
Hi,
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
'reversed' yields the items in reverse order; it needs the last item first.
Iterators yield items
Tim Chase wrote:
> On 2016-03-06 19:29, Sven R. Kunze wrote:
>> what's the reason that reversed(zip(...)) raises as a TypeError?
>>
>> Would allowing reversed to handle zip and related functions lead to
>> strange errors?
>
> Peculiar, as this works in 2.x but falls over in 3.x:
>
> $ python
>
On 2016-03-06 12:38, Tim Chase wrote:
> On 2016-03-06 19:29, Sven R. Kunze wrote:
> > what's the reason that reversed(zip(...)) raises as a TypeError?
>
> I'm not sure why reversed() doesn't think that the thing returned by
> zip() isn't a sequence.
Ah, a little more digging suggests that in 2.x,
Sven R. Kunze wrote:
> what's the reason that reversed(zip(...)) raises as a TypeError?
>
> Would allowing reversed to handle zip and related functions lead to
> strange errors?
In Python 3 zip() can deal with infinite iterables -- what would you expect
from
reversed(zip(count()))
?
If all
(Sorry for top-posting)
No TypeError here:
Python 2.7.2 (default, Nov 2 2015, 01:07:37) [GCC 4.9 20140827 (prerelease)]
on linux4
Type "help", "copyright", "credits" or "license" for more information.
>>> ten = range(10)
>>> reversed(zip(ten, ten))
>>> list(reversed(zip(ten, ten)))
[(9, 9), (
On 2016-03-06 19:29, Sven R. Kunze wrote:
> what's the reason that reversed(zip(...)) raises as a TypeError?
>
> Would allowing reversed to handle zip and related functions lead to
> strange errors?
Peculiar, as this works in 2.x but falls over in 3.x:
$ python
Python 2.7.9 (default, Mar 1 201