verifying type of socket object?

Peter Wang pzw1 at
Thu Nov 1 18:51:05 CET 2001

in my code, i'd like to verify that i get passed a socket object.
however, i'm having some trouble figuring out what exactly represents
the "socket type".  the main problem is that socket.socket() doesn't
return instances of socket.SocketType:

>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> socket.SocketType
<type 'socket'>
>>> isinstance(x, socket.SocketType)
>>> x
<socket._socketobject instance at 011232A4>
>>> isinstance(x, socket._socketobject)

my question is, how can i achieve the effect of the last isinstance()
call without having to touch an underscored member of the socket


More information about the Python-list mailing list