Re: iter

2010-08-24 Thread Aahz
In article , Terry Reedy wrote: > >Changing a list while iterating through it is possible, sometimes >useful, but error prone, especially with insert or delete. Changing a >dict while iterating through it is prohibited since the iteration order >depends on the exact internal structure. That in

Re: iter

2010-08-09 Thread Steven D'Aprano
On Mon, 09 Aug 2010 09:11:37 -0700, daryn wrote: > I'm just playing around with the iter function and I realize that I can > use the iterator returned by it long after the original object has any > name bound to it. Yes, the same as everything else in Python. Iterators aren't unique here. >>> a

Re: iter

2010-08-09 Thread Terry Reedy
On 8/9/2010 12:11 PM, daryn wrote: I'm just playing around with the iter function and I realize that I can use the iterator returned by it long after the original object has any name bound to it. Example: a=[1,2,3,4] b=iter(a) b.next() 1 a[1]=99 Changing a list while iterating through it i

Re: iter

2010-08-09 Thread Peter Otten
daryn wrote: > I'm just playing around with the iter function and I realize that I > can use the iterator returned by it long after the original object has > any name bound to it. Example: > a=[1,2,3,4] b=iter(a) b.next() > 1 a[1]=99 a[3]=101 del a b.next() > 99 b

Re: iter with stepsize

2008-10-15 Thread Alan G Isaac
Alan G Isaac <[EMAIL PROTECTED]> writes: If I have a sequence, I can get every other or every fifth element by slicing. Is there an equivalent for iterators? On 10/15/2008 11:12 PM Paul Rubin apparently wrote: itertools.islice Oh, of course. I'm a bit embarrassed not to have thought to lo

Re: iter with stepsize

2008-10-15 Thread Paul Rubin
Alan G Isaac <[EMAIL PROTECTED]> writes: > If I have a sequence, I can get every other or every fifth > element by slicing. Is there an equivalent for iterators? itertools.islice -- http://mail.python.org/mailman/listinfo/python-list

Re: iter(lambda:f.read(8192),'')

2008-02-25 Thread Gabriel Genellina
En Sun, 24 Feb 2008 10:18:31 -0200, Dustan <[EMAIL PROTECTED]> escribió: > On Feb 24, 5:11 am, gert <[EMAIL PROTECTED]> wrote: >> what is the difference between iter(lambda:f.read(8192), ') and >> iter(f.read(8192),'') ? > > iter(lambda:f.read(8192), '') (what you probably meant) is what it > lo

Re: iter(lambda:f.read(8192),'')

2008-02-24 Thread gert
aha ok got it :) -- http://mail.python.org/mailman/listinfo/python-list

Re: iter(lambda:f.read(8192),'')

2008-02-24 Thread Dustan
On Feb 24, 5:11 am, gert <[EMAIL PROTECTED]> wrote: > what is the difference between iter(lambda:f.read(8192), ') and > iter(f.read(8192),'') ? One does not work, and one is syntactically incorrect: >>> iter(f.read(8192),'') Traceback (most recent call last): File "", line 1, in iter(f.re

Re: iter(callable, sentinel)

2006-07-27 Thread Simon Forman
Will McGugan wrote: > Hi, > > I've been using Python for years, but I recently encountered something > in the docs I wasnt familar with. That is, using two arguements for > iter(). Could someone elaborate on the docs and maybe show a typical use > case for it? > > > Thanks, > > Will McGugan > > --

Re: iter(callable, sentinel)

2006-07-27 Thread Simon Forman
Will McGugan wrote: > Hi, > > I've been using Python for years, but I recently encountered something > in the docs I wasnt familar with. That is, using two arguements for > iter(). Could someone elaborate on the docs and maybe show a typical use > case for it? > > > Thanks, > > Will McGugan > > --

Re: iter(callable, sentinel)

2006-07-27 Thread Simon Forman
Will McGugan wrote: > Hi, > > I've been using Python for years, but I recently encountered something > in the docs I wasnt familar with. That is, using two arguements for > iter(). Could someone elaborate on the docs and maybe show a typical use > case for it? > > > Thanks, > > Will McGugan > > --