Incomplete Format

Anyone who is getting ValueError: incomplete format exceptions when doing a string format in python should understand that the part inside the () is just an array lookup. You still need a format type after it.

I have %(count) %(adj) %(noun)

doesn’t work since you didn’t say they were integers and strings. You need to do

I have %(count)i %(adj)s %(noun)s

which is the same as

I have %i %s %s

with position indexed values.

Posted on 01 June 2009 by Paul Tarjan

If you liked this, you might also like...