The empty string ('') is a pertectly valid key for a dictionary, but I can not reference it using the Format String Syntax
data = { 'a' : 'hello' , '' : 'bye' }
print '{a:<14s}'.format(**data)
print '{:<14s}'.format(**data)
Which outputs:
hello
Traceback (most recent call last):
File "xxx.py", line 3, in <module>
print '{:<14s}'.format(**data)
IndexError: tuple index out of range
Is there any way of referencing that key ... as a dictionary key! I can not convert the data to tuples; a bit of background: I am doing some auto-formatting based on a generic format spec which gets converted to Format String Syntax using dicts as data for the formatting. That is, I can not do this:
print '{0:<14s}'.format(data[''])
The data must always be passed to format as **data (basically, because I am doing a generic .format(**data) in my formatter class)