Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36344 > unrolled thread

what’s the difference between socket.send() and socket.sendall() ?

Started by"iMath" <2281570025@qq.com>
First post2013-01-07 18:35 +0800
Last post2013-01-08 02:54 +1100
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  what’s the difference between socket.send() and socket.sendall() ? "iMath" <2281570025@qq.com> - 2013-01-07 18:35 +0800
    Re: what’s the difference between socket.send() and socket.sendall() ? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-07 14:17 +0100
    Re: what’s the difference between socket.send() and socket.sendall() ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-07 15:28 +0000
      Re: what’s the difference between socket.send() and socket.sendall() ? Chris Angelico <rosuav@gmail.com> - 2013-01-08 02:54 +1100

#36344 — what’s the difference between socket.send() and socket.sendall() ?

From"iMath" <2281570025@qq.com>
Date2013-01-07 18:35 +0800
Subjectwhat’s the difference between socket.send() and socket.sendall() ?
Message-ID<mailman.216.1357558243.2939.python-list@python.org>
<p class="MsoNormal"><tt><span lang="EN-US" style="font-size: 12pt; color: white; background-color: rgb(68, 110, 248); background-position: initial initial; background-repeat: initial initial; ">what’s the difference between socket</span></tt><tt><span lang="EN-US" style="font-size: 12pt; ">.send() and&nbsp;<span style="color: white; background-color: rgb(68, 110, 248); background-position: initial initial; background-repeat: initial initial; ">socket</span>.sendall() ?</span></tt>
</p>

<p class="MsoNormal"><tt><span lang="EN-US" style="font-size:12.0pt">It is so hard
for me to tell the <span style="color:white;background:#446EF8">difference
between them from the python doc<o:p></o:p></span></span></tt></p>

<p class="MsoNormal"><tt><span lang="EN-US" style="font-size:12.0pt;color:white;
background:#446EF8">so what is the difference between them ?<o:p></o:p></span></tt></p>

<p class="MsoNormal"><tt><span lang="EN-US" style="font-size:12.0pt;color:white;
background:#446EF8">and each one is suitable for which case ?<o:p></o:p></span></tt></p>

[toc] | [next] | [standalone]


#36349

FromThomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Date2013-01-07 14:17 +0100
Message-ID<kcehu4$gsn$1@r03.glglgl.gl>
In reply to#36344
Am 07.01.2013 11:35 schrieb iMath:
> what’s the difference between socket.send() and socket.sendall() ?
>
> It is so hard for me to tell the difference between them from the python doc
>
> so what is the difference between them ?
>
> and each one is suitable for which case ?
>

The docs are your friend. See

http://docs.python.org/2/library/socket.html#socket.socket.sendall

| [...] Unlike send(), this method continues to send data from string
| until either all data has been sent or an error occurs.

HTH,

Thomas

[toc] | [prev] | [next] | [standalone]


#36356

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-01-07 15:28 +0000
Message-ID<50eae991$0$30003$c3e8da3$5496439d@news.astraweb.com>
In reply to#36344
On Mon, 07 Jan 2013 18:35:20 +0800, iMath wrote:

> <p class="MsoNormal"><tt><span lang="EN-US" style="font-size: 12pt;
> color: white; background-color: rgb(68, 110, 248); background-position:
> initial initial; background-repeat: initial initial; ">what’s the
> difference between socket</span></tt><tt><span lang="EN-US"
> style="font-size: 12pt; ">.send() and&nbsp;<span style="color: white;
> background-color: rgb(68, 110, 248); background-position: initial
> initial; background-repeat: initial initial; ">socket</span>.sendall()
> ?</span></tt> </p>


Please re-send your question as text, instead of as HTML (so-called "rich 
text"). Since many people are reading this forum via Usenet, sending HTML 
is considered abusive. This is a text newsgroup, not a binary newsgroup.

If you *must* use a client that sends HTML, please make sure that it 
ALWAYS sends a plain text version of your message as well. But here are 
eight reasons you should not rely on fancy formatting (colours, fonts, 
bold, etc.) in text-based media such as email (or news):

- HTML code in email is one of the top 3 signs of spam. Many people
  send "rich text" email straight to the trash as a way of eliminating
  spam.

- HTML code in email is a privacy and security risk. For example,
  that means that the sender can track whether or not you have read
  the email using "web bugs" whether or not you consent to being
  tracked. There are viruses, spyware and other malware that can be
  transmitted through HTML code in email. For this reason, many
  people filter HTML email straight to the trash.

- HTML code forces your choice in font, font size, colours, etc. on
  the reader. Some people prefer to read emails using their own
  choice of font rather than yours, and consider it rude for others
  to try to force a different font. Sending white text on coloured 
  background is especially nasty, because it hurts readability of
  even for people with perfect vision.

- Even if readers don't mind the use of "rich text" in principle, in
  practice once they have received enough emails with pink text on a
  purple and yellow background with blinking stars and dancing fairies
  all over the page, in pure self-defence they may disable or delete 
  HTML emails.

- Use of colour for emphasis discriminates against the approximately
  10% of the male population who are colour-blind.

- Use of italics or other formatting may discriminate against those 
  who are blind and using screen readers to "read" their email. I 
  once was on a maths mailing list for about three years before I
  realised that the most prolific and helpful person there was as 
  blind as a bat.

- Programming is a *text-based* activity. Code depends on WHAT you
  write, not its colour, or the font you use, or whether there are
  smiley faces in the background winking at you. So especially in
  programming circles, many people find HTML code in emails to be a
  distraction and an annoyance. Being able to express yourself in 
  plain text without colours and fonts is a good practice for any
  programmer to get used to.

- Even if you think that people who dislike HTML emails are wrong, or
  silly, or being precious, or completely nuts, nevertheless you should
  indulge us. You are asking for free advice. It does not pay for you to
  offend or annoy those you are asking for help. 


(Apologies to anyone on the "tutor" mailing list who has already seen 
this message earlier today.)



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#36359

FromChris Angelico <rosuav@gmail.com>
Date2013-01-08 02:54 +1100
Message-ID<mailman.226.1357574091.2939.python-list@python.org>
In reply to#36356
On Tue, Jan 8, 2013 at 2:28 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> I
>   once was on a maths mailing list for about three years before I
>   realised that the most prolific and helpful person there was as
>   blind as a bat.

And that, I think, is what s/he would have most wanted: three years
(more, most likely) without any sort of special treatment. It's all
very well to talk about anti-discrimination laws, but on the internet,
nobody knows you're a bat, if I can mangle that expression without
offending people. We have some excellent people on a couple of MUDs
I'm on who are, similarly, blind and using screen-readers. Again, you
don't even know that that's the case until/unless a question comes out
about some piece of ASCII art (which there's a very VERY little of in
Threshold), or some client-specific question hints at the fact that
s/he is using one of the reader-friendly clients (which are fairly
ugly to the sighted).

As to the use of color for emphasis, though - I don't think the OP
used it like that. I've no idea what the significance of white-on-blue
words was, there; it completely eludes me. Maybe he was sending a
secret message in the color codes? In any case, Steven's eight reasons
are absolutely right; when HTML code isn't adding information, it
should be stripped, and when it is adding information, you risk a
large proportion of people not seeing it. So there's never a good time
to use HTML.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web