verifying type of socket object?
Thomas Jensen
thomasNO at SPAM.obscure.dk
Thu Nov 1 13:02:33 EST 2001
More information about the Python-list mailing list
Thu Nov 1 13:02:33 EST 2001
- Previous message (by thread): verifying type of socket object?
- Next message (by thread): verifying type of socket object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Peter Wang <pzw1 at cor-no-spam-nell.edu> wrote in news:+YrhO+rceV33qbXjWckIp8NUkWP4 at 4ax.com: > 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: It does here, se below >>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>>> socket.SocketType <type 'socket'> isinstance(x, >>>> socket.SocketType) 0 x <socket._socketobject instance at >>>> 011232A4> isinstance(x, socket._socketobject) 1 Whats your system and Python version? (Mine is Python 2.1.1 on FreeBSD4.4-RELEASE) Here's what I got: >>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> socket.SocketType <type 'socket'> >>> isinstance(x, socket.SocketType) 1 >>> x <socket object, fd=8, family=2, type=1, protocol=0> >>> isinstance(x, socket._socketobject) 0 And adding: >>> type(x) == socket.SocketType 1 -- Best Regards Thomas Jensen
- Previous message (by thread): verifying type of socket object?
- Next message (by thread): verifying type of socket object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list