[Python-ideas] socket.sendall() "counter" parameter
Giampaolo Rodola'
g.rodola at gmail.com
Fri Apr 18 14:06:05 CEST 2014
On Fri, Apr 18, 2014 at 1:52 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Apr 18, 2014 at 9:34 PM, Giampaolo Rodola' <g.rodola at gmail.com>
> wrote:
> > With current socket.sendall() implementation if an error occurs it's
> > impossible to tell how much data was sent. As such I'm wondering whether
> it
> > would make sense to add a "counter" parameter which gets incremented
> > internally:
> >
> > sent = 0
> > try:
> > sock.sendall(data, counter=sent)
> > except socket.error as err:
> > priint("only %s bytes were sent" % sent)
>
> That doesn't work with a straight integer; there's no way for
> sendall() to modify your integer. It'd need to be some mutable type,
> or else the new value would have to be returned somewhere.
>
Ouch! It seems you're right, I didn't take that into account.
--
Giampaolo - http://grodola.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140418/683a51f6/attachment.html>
More information about the Python-ideas
mailing list