Printing formatted strings from a dictionary

Josiah Carlson jcarlson at uci.edu
Fri May 21 15:16:03 EDT 2004


> Uuuaaah, I can't stop learning YOU(python). Couldn't verify
> the above example. Maybe some fault happened to you because the code
> which raised the KeyError and the successfull one are the same for me.
> But the following works:
> 
>>>>d={'1':2}   # Remark the quotmarks '1'
>>>>'%(1)i'%d
> 
> '2'

Right, I forgot to rebind d.  My bad, but it is great that you figured 
it out.

  - Josiah



More information about the Python-list mailing list