using generators with format strings
Christopher T King
squirrel at WPI.EDU
Tue Jul 27 09:15:57 EDT 2004
On Mon, 26 Jul 2004, Calvin Spealman wrote:
> The generators are not list-type objects, but iterators. Because the %
> operator does not operate on iterators directly (because, presumably, you
> may be wanting to print the iterator itself, not the items it iterates
> over), you must construct a list out of it, which can be done very easily,
> as you can see.
Not quite, because for the same reason as generators, lists are passed to
% as a single argument. The arguments must be contained in a tuple
(tuple(myvalues()) does nicely).
More information about the Python-list
mailing list