print format
Will Ware
wware at world.std.com
Wed Jul 26 12:13:13 EDT 2000
Curtis Jensen (cjensen at bioeng.ucsd.edu) wrote:
> [Python's format-string mechanism]
> only works with tuples, not lists. The % operator with strings
> requires tuples. I'm not sure why the chose to make this limitation.
> The following code gives this error.
> a = [1,2,3,4,5]
> print (5*"%5i ") % a
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: illegal argument type for built-in operation
This is all true, but it's not too bad because you can easily convert
a list to a tuple using the tuple() function. Just type
print (5*"%5i ") % tuple(a)
and you should be OK.
--
- - - - - - - - - - - - - - - - - - - - - - - -
Resistance is futile. Capacitance is efficacious.
Will Ware email: wware @ world.std.com
More information about the Python-list
mailing list