blackknight blackknight - 1 year ago 82
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):

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download