Python dictionary to store socket objects

python

Solution

Yes:

>>> import socket
>>> s = socket.socket()
>>> d = {"key" : s}
>>> d
{'key': <socket._socketobject object at 0x00CEB5A8>}

Problem

Can we store socket objects in a Python dictionary. I want to create a socket, store socket object, do some stuff and then read from the socket(search from dictionary to get socketobject).

Original source