Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60300
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'assign': 0.07; 'string': 0.09; 'happen.': 0.09; 'newline': 0.09; 'subject:Python3': 0.09; 'terminated': 0.09; '24,': 0.16; 'differs': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interpreter,': 0.16; 'repl': 0.16; 'script,': 0.16; 'sys.stdout': 0.16; 'written.': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'handles': 0.22; 'skip:_ 20': 0.27; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'there,': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'length': 0.61; 'between': 0.67; 'frank': 0.68; 'confusing': 0.84; 'improvement,': 0.84; 'overall,': 0.84; 'partial': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=vDOQQdk4qyY785kdS2SQf0KbN4ADSJIFZUJJRdjlbAo=; b=WmTNvEqd1XXEsUu2za5tXm5fRcPzBJ37msyiU1gPDgJ1Jb1z1oJlWNzrynMBlnscXd PV2mLs9eAkPGEhXu63B8fhqZjJJftPZ0pBvtYsFnjS8vTIqwuf4T4vhjXDV6MTqyMddU me3tEqsl7Ma0nxBB5G4SEmr1jXk48AfwYloK89/nbPj+ibYH7RStSksGyAvBu2t9EdlJ 8mxd8XLjsRPvyR5LV5nmhWsTbXZ3aZQl9vd6UxJg6YlWAdFGt6fW3MOV446/moAnPQUo MW2g4GVlEamWfLL/Jl6u9FPoRCru1iM+fWv14G22itGpt+HbTdReATGlj1F4RIfGDWEf pkRA== |
| MIME-Version | 1.0 |
| X-Received | by 10.69.31.1 with SMTP id ki1mr8253685pbd.124.1385216178955; Sat, 23 Nov 2013 06:16:18 -0800 (PST) |
| In-Reply-To | <l6qacb$ap$1@ger.gmane.org> |
| References | <l6qacb$ap$1@ger.gmane.org> |
| Date | Sun, 24 Nov 2013 01:16:18 +1100 |
| Subject | Re: sys.stdout and Python3 |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3084.1385216188.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385216188 news.xs4all.nl 15986 [2001:888:2000:d::a6]:42748 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60300 |
Show key headers only | View raw
On Sun, Nov 24, 2013 at 12:26 AM, Frank Millman <frank@chagford.com> wrote:
> for i in range(10):
> sys.stdout.write('.')
> sys.stdout.flush()
> time.sleep(1)
> sys.stdout.write('\n')
>
> I tried it under Python3, and found that it differs in two ways -
>
> 1. Each 'write' is terminated by a newline
> 2. Each 'write' appends the length of the string written.
Only in the interactive interpreter, where return values get printed.
In a script, that won't happen. To prevent that from happening
interactively, just assign the result to something:
for i in range(10):
_=sys.stdout.write(".")
sys.stdout.flush()
There definitely is a difference between Py2 and Py3 there, but it's
nothing to do with sys.stdout - it's a change in the REPL (interactive
interpreter, Read/Eval/Print Loop) and how it handles return values
inside loops. I think it's an improvement, overall, though it is a
little confusing when you work with partial output.
ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: sys.stdout and Python3 Chris Angelico <rosuav@gmail.com> - 2013-11-24 01:16 +1100
Re: sys.stdout and Python3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-24 14:31 +0000
Re: sys.stdout and Python3 Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:39 +1100
csiph-web