[Tutor] TypeError: not all arguments converted during string formatting

Steven D'Aprano steve at pearwood.info
Mon Jul 9 17:47:42 CEST 2012


Keitaro Kaoru wrote:
[...]
> TypeError: not all arguments converted during string formatting
[...]
> 		return self.html % ca
> 
> cant seem to find out whats wrong with it


Try experimenting at the interactive interpreter:


[steve at ando ~]$ python
Python 2.6.7 (r267:88850, Mar 10 2012, 12:32:58)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
py> "%s - %s - %s" % (1, 2, 3)
'1 - 2 - 3'

py> "%s - %s - %s" % (1, 2)  # Not enough values
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string

py> "%s - %s - %s" % (1, 2, 3, 4)  # Too many values
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting


-- 
Steven


More information about the Tutor mailing list