faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 4 people (75%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

How would I check to see if an object is an instance of a socket?

Jun 10th, 2000 16:22
unknown unknown, Moshe Zadka, Jerome Chan


Use the type() function:

>>> type(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
<type 'socket'>

In the socket documentation:

if type(s)==socket.SocketType: print "hello"