How to iterate a sequence, with skipping the first item?

alex23 wuwei23 at gmail.com
Tue Aug 12 02:58:08 EDT 2008


On Aug 12, 4:51 pm, ray <hanl... at gmail.com> wrote:
> A container object provides a method that returns an iterator object.
> I need to iterate the sequence with that iterator, but need to skip
> the first item. I can only iterate the whole sequence with:
> for x in container.iterChildren():
> How to skip the first item? It seems that it's a simple question.
> Could somebody help me? Thanks.

Does the for loop -have- to contain the reference to iterChildren? If
you can modify that, you can always manually step past the first item:

children = container.iterChildren()
children.next()
for x in children: ...



More information about the Python-list mailing list