Another Socket in Python

Peter Hansen peter at engcorp.com
Sat Aug 17 19:53:47 CEST 2002


Steven wrote:
> 
> IIRC one thing to remember with select is that  you don't pass the actual
> socket in a list, you pass the file descriptor/number. You can get this by
> using the socket objects fileno() method.
[...]
> exception_socks=select.select([s.fileno()],[],[], TIMEOUT)

Actually, Python handles this for you, as the docs note:

  "The first three arguments are lists of `waitable objects': 
   either integers representing file descriptors or objects with 
   a parameterless method named fileno() returning such an integer."

So you can just pass a reference to the socket instead.

-Peter



More information about the Python-list mailing list