why does the % string format operator only take tuples?

Ram Bhamidipaty ramb at synopsys.com
Tue Apr 3 13:48:15 EDT 2001


Its possible to do this:
  print "%d %d" % (1,2)
but not this:
  print "%d %d" % [1,2]

Why?

I know I can convert the list to a tuple. I want to know
if there is a reason for % not taking lists as well as tuples.

Does anyone else think it would be a good idea of the % operator
were extended to also handle lists?

-Ram



More information about the Python-list mailing list