Printing with interspersed element
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Oct 31 03:26:14 EDT 2008
On Thu, 30 Oct 2008 16:40:17 -0500, Grant Edwards wrote:
> If you want to do it "on the fly", then try something like this:
>
> iter = [1,2,3,4,5].__iter__()
> sys.stdout.write(str(iter.next()))
> for n in iter:
> sys.stdout.write(',' +str(n))
Maybe without shadowing the built in `iter()` and without calling the
"magic method" directly:
iterator = iter([1, 2, 3, 4, 5])
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list