Sep 19, 2008 18:06
So, things were never too simple in C++ world when it came to funky formatting while doing all the cin cout business. So, Python also follows C-like format specification strings and it's all happy and cool most of the time. Except, when it comes to shit like this:
print args = dict([x for x in mydict.items() if x[0] in ['xx', 'yy', 'zz', 'aa', 'bb']])
print "%(xx)d, %(yy)d, %(zz)d, %d(aa), %(bb)f" % args
This gave me:
{'xx': 99050L, 'bb': 3.1360260922879597, 'yy': 2556, 'zz': 2, 'aa': 0}
TypeError: not enough arguments for format string
Zoink! What the heck is going on here? After some half an our of frantic debugging (i.e. print abuse), I figured. I'd written %d(aa) instead of %(aa)d.
So much for format specifier funk.
bloopers,
typos,
python