Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38130
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!nuzba.szn.dk!pnx.dk!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jabba.laci@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'that?': 0.05; 'over,': 0.07; "'.'": 0.09; "'w',": 0.09; 'descriptor': 0.09; 'newline,': 0.09; 'stdout': 0.09; 'sys.stdout': 0.09; 'def': 0.10; 'script.': 0.17; 'switched': 0.17; 'thanks,': 0.18; 'python?': 0.20; 'visible': 0.22; "i'd": 0.22; 'second': 0.24; 'checking': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.28; 'perl': 0.29; 'mode': 0.30; 'file': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'received:209': 0.37; 'far': 0.37; 'well.': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'skip:u 10': 0.60; 'back': 0.62; 'subject:off': 0.65; 'forth': 0.75; 'remember,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=xSyrqAAKAeE11V4LhSPZITPOyQBeJwutfurGQoPJAD4=; b=Tb27ReXKyqMCt+Z+6ZEv6N1vGe9IinISivH+bj2GUZLVbHV1ayBHAhqgzJGzLHgPye JSC0TEwZiyKXEm7F3uuRkxX24q8vIraQk+ETF/hPJluCfjS7589VDwHx3oGcuLr6iNt0 N1SwyUNWsiQJRp2n2m25WW5es3anAIQ244VY03p+xevNJYxFc0dQs3NIRCdzpxoNKBi0 IRVW4CroKdXpZg52K7kc08CbRnmfcPODuXu2UH8mbX9t5yUxAVt+jmzzpQ7Z0KbNDJxn 0a4z64Sc5pjbb2aczrhkkSpVqKLNK/y0TpsspwkQaNa56udDVvGlmx+uI8R++LDSO1lX dPgg== |
| X-Received | by 10.182.0.19 with SMTP id 19mr16098478oba.15.1359997980300; Mon, 04 Feb 2013 09:13:00 -0800 (PST) |
| MIME-Version | 1.0 |
| From | Jabba Laci <jabba.laci@gmail.com> |
| Date | Mon, 4 Feb 2013 18:12:39 +0100 |
| Subject | autoflush on/off |
| To | Python mailing list <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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1326.1359997988.2939.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1359997988 news.xs4all.nl 6942 [2001:888:2000:d::a6]:37043 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38130 |
Show key headers only | View raw
Hi,
I'd like to set autoflush on/off in my script. I have a loop that is
checking something and every 5 second I want to print a '.' (dot). I
do it with sys.stdout.write and since there is no newline, it is
buffered and not visible immediately. I have this solution to use
unbuffered output:
autoflush_on = False
def unbuffered():
"""Switch autoflush on."""
global autoflush_on
# reopen stdout file descriptor with write mode
# and 0 as the buffer size (unbuffered)
if not autoflush_on:
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
autoflush_on = True
I call unbuffered() once and it works well. However, when this loop is
over, I'd like to set the output back to buffered. How to do that? As
far as I remember, in Perl it was simply $| = 1 and $| = 0. Can it
also be switched back and forth in Python?
Thanks,
Laszlo
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
autoflush on/off Jabba Laci <jabba.laci@gmail.com> - 2013-02-04 18:12 +0100 Re: autoflush on/off garabik-news-2005-05@kassiopeia.juls.savba.sk - 2013-02-04 18:51 +0000 Re: autoflush on/off Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-02-04 19:24 +0100
csiph-web