Little novice program written in Python

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Apr 25 12:35:05 CEST 2008


On Fri, 25 Apr 2008 10:24:16 +0200, Robert Bossy wrote:

> John Machin wrote:
>> On Apr 25, 5:44 pm, Robert Bossy <Robert.Bo... at jouy.inra.fr> wrote:
>>   
>>> Peter Otten wrote:
>>> If the OP insists in not examining a[0] and a[1], this will do exactly
>>> the same as the while version:
>>>
>>> for p in a[2:]:
>>>     if p:
>>>         print p
>>>
>>>     
>>
>> ... at the cost of almost doubling the amount of memory required.
> Indeed. Would it be a sensible proposal that sequence slices should 
> return an iterator instead of a list?

I don't think so as that would break tons of code that relies on the
current behavior.  Take a look at `itertools.islice()` if you want/need
an iterator.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list