Hi Peter,

> As you already learned the csv module is the best tool to address your
> problem.

Yup - it's almost going to make my little coding exercise trivial. :)

> However, I'd like to show a generic way to get an extra item in a for-
> loop.

[snip]

> Here's a self-contained example:
> 
> >>> items = "alpha- beta gamma- delta- epsilon zeta".split()
> >>> it = iter(items)
> >>> for item in it:
> ...     while item.endswith("-"):
> ...             item += next(it)
> ...     print item
> ...
> alpha-beta
> gamma-delta-epsilon
> zeta

Perfect - that's essentially what I was trying to do, but I doubt it
would have occurred to me to create my own iterator and make use of it.

Thanks for this example too - nice and easy to understand.

Steve.


This email and any attachment to it are confidential.  Unless you are the 
intended recipient, you may not use, copy or disclose either the message or any 
information contained in the message. If you are not the intended recipient, 
you should delete this email and notify the sender immediately.

Any views or opinions expressed in this email are those of the sender only, 
unless otherwise stated.  All copyright in any Capita material in this email is 
reserved.

All emails, incoming and outgoing, may be recorded by Capita and monitored for 
legitimate business purposes. 

Capita exclude all liability for any loss or damage arising or resulting from 
the receipt, use or transmission of this email to the fullest extent permitted 
by law.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to