what does [sock] = func() mean?

What does this line of code mean, from tornado?

[sock] = netutil.bind_sockets(None, 'localhost', family=socket.AF_INET)

I understand these assignments: list[index] = val, list[index1:index2] = list2, but I’ve never seen that from Tornado.

Best answer

The function returns an element inside a container, and the author wants sock bound to the element, not to the container.

Here is a more simple example of that syntax:

>>> def foo():
...   return ['potato']
>>> [p] = foo()
>>> p