blackknight blackknight - 2 months ago 4
Python Question

What does this strange format string "{[[[]}" do?

I come across the below in some code from an ex employee.

the code is not called, from anywhere, but my question is can it actually do something useful as it is?

def xshow(x):


That is a format string with an empty argument name and an element index (the part between [ and ] for a key [[[ (those indices don't have to be integers). It will print the value for that key.


xshow({'[[[': 1})

will print 1