[Python-Dev] Iterable sockets?
Fri, 14 Mar 2003 14:11:41 +1100
>> The short answer is that it does, but not very tidily - by turning the
>> socket object into a file object, I lose the original socket object
>> functionality (for example, shutdown()).
>You can just keep the socket around though.
Yes. Which has always struck me as slightly ugly.
>> At another level, the concept of a "file-like" object is a very common
>> python idiom - socket is the odd one out these days.
>> It's really not a big deal - we could regularise the interface at the
>> cost of more implementation complexity.
>I'm not sure if I'd call that regularizing. It would by necessity
>become some kind of odd mixture.
I guess you would keep the send() and recv() interfaces for raw access, and
add read(), write(), readlines(), etc, which would be buffered. I'd chose
to then view it as a superset of a file-like object.
>In any case, I find the file abstraction a bit arcane too. Maybe we
>should strive to replace all these with something better in Python 3.0, to
>be prototyped in the standard library starting with 2.4.
And get rid of stdio along the way, with any luck... 8-)
It would also be nice to make the buffering play nicely with
select()/poll()-threaded applications... if we're talking about
Andrew McNamara, Senior Developer, Object Craft