Tony Meyer wrote: > [Nick Coghlan] > >>"Print as statement" => printing sequences nicely is a pain > > > What's wrong with this? > > >>>>print range(10) > > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > >>>>print tuple("string") > > ('s', 't', 'r', 'i', 'n', 'g')
> > This is a serious question - that's how I would expect a print function to > work anyway. Py> print (x*x for x in range(10)) <generator object at 0x00AE71C0> Oh, wait, this is what I actually meant: Py> print " ".join(map(str, (x*x for x in range(10)))) 0 1 4 9 16 25 36 49 64 81 Printing the contents of an arbitrary iterable is harder than it should be. Many iterables (including the builtin ones) have a reasonable default display, but a non-default display (e.g. linefeed separated instead of comma separated) isn't the most obvious thing to express. I thought making print a function solved that problem, but it doesn't really. So I'm currently exploring a different approach involving string formatting. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.blogspot.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com