problems using % in strings with %(var)s replacements

Thomas Weholt thomas at
Wed May 23 11:56:31 CEST 2001

Say I got a string s = "%(number)s among 50% are efficient for

I want to replace 'number' with 42 and 'customer_name' with Acme Inc.

Trying to do a simple
>>> s % {'number':42,'customer_name':'Acme Inc.'}
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: not enough arguments for format string

I see the % in 50% is the problem but how can I use the %-char in strings
and still use %(...)s replacements??


More information about the Python-list mailing list