Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36946
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!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.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.04; 'case.': 0.05; 'level,': 0.07; 'python': 0.09; 'etc).': 0.09; 'mess': 0.09; 'referencing': 0.09; 'stdout': 0.09; 'stringio': 0.09; 'sys.stdout': 0.09; 'subject:python': 0.11; 'file,': 0.15; '(so,': 0.16; 'buffering,': 0.16; 'fiddle': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'goal,': 0.16; 'output?': 0.16; 'sees': 0.16; 'way;': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'otherwise,': 0.20; 'sort': 0.21; 'fairly': 0.21; 'assuming': 0.22; 'pipe': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'separate': 0.27; 'c++': 0.27; 'easiest': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'there.': 0.28; 'i/o': 0.29; 'case,': 0.29; 'fri,': 0.30; 'code': 0.31; '(and': 0.32; 'file': 0.32; 'running': 0.32; 'function.': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; '(with': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'process,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'usual': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'high': 0.61; 'assistance': 0.63; 'offer': 0.65; 'physical': 0.69; '2013': 0.84; '2:02': 0.84; 'etc,': 0.84; 'redirecting': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=scdsSzaZ3YG5Vqsj5Cf7aToO84lPS5kxtg3uz7h8uew=; b=UQe5qKZ76LA14MCevJ+6gKox0espZte/BQ1XjgWppz6AwO8nkKK131F+mNfiWsYVfV Ft4lmtZ8UHhlLxNxT1nZDL1/P9LG4E3+vmIMg+FvjCZgPZXq9e+K9x2zMEDtSSKtczHp 7UXykBFuuuxXM4E2/8uprPRHYPY/9sABdMdM0ni1OeWPfwXJjqbKNMXWQMhys286dXFP Y56igtPLWh8k68D7ZhuXqqC7DE2C+7RUc3Mxs0dpoaXFGNy0rus0rAVyL3i2Qq/W3XOg xrCDg2Vl3robvJPLeeegbUIAEqC1Fph/r0zgu8U1neHRQfPjnbGp9CNvVH0uKGtXaIwY 8PWw== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.29.109 with SMTP id j13mr876428vdh.111.1358437344155; Thu, 17 Jan 2013 07:42:24 -0800 (PST) |
| In-Reply-To | <2699150a-cf67-46ac-b863-34c92bffceaf@googlegroups.com> |
| References | <2699150a-cf67-46ac-b863-34c92bffceaf@googlegroups.com> |
| Date | Fri, 18 Jan 2013 02:42:24 +1100 |
| Subject | Re: python sys.stdout and C++ iostreams::cout |
| 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 | <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.592.1358437352.2939.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1358437352 news.xs4all.nl 6857 [2001:888:2000:d::a6]:57465 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:36946 |
Show key headers only | View raw
On Fri, Jan 18, 2013 at 2:02 AM, Utpal Sarkar <doetoe@gmail.com> wrote: > I was assuming that sys.stdout would be referencing the same physical stream as iostreams::cout running in the same process, but this doesn't seem to be the case. That's more-or-less true, but there will likely be separate buffering, so even without redirection you might see some oddities. But the problem with your code is that you're not actually redirecting stdout in any way; you're catching, at a fairly high level, everything that Python would otherwise have sent there. Is there any way that you can get the C++ code to offer a way to redirect its output? Otherwise, you're going to have to fiddle around with the usual mess of I/O redirection (with dup2), and you can only send it to what the OS sees as a file (so, no StringIO buffer). So to achieve your goal, you may need either a temporary physical file, or some sort of pipe (and worry about reading from it before it fills up, etc, etc). There may be alternatives, but in any case, the easiest way is going to be with some assistance from the C++ function. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
python sys.stdout and C++ iostreams::cout Utpal Sarkar <doetoe@gmail.com> - 2013-01-17 07:02 -0800
Re: python sys.stdout and C++ iostreams::cout Nobody <nobody@nowhere.com> - 2013-01-17 15:35 +0000
Re: python sys.stdout and C++ iostreams::cout Chris Angelico <rosuav@gmail.com> - 2013-01-18 02:42 +1100
Re: python sys.stdout and C++ iostreams::cout Utpal Sarkar <doetoe@gmail.com> - 2013-01-17 07:51 -0800
Re: python sys.stdout and C++ iostreams::cout Chris Angelico <rosuav@gmail.com> - 2013-01-18 02:54 +1100
Re: python sys.stdout and C++ iostreams::cout Utpal Sarkar <doetoe@gmail.com> - 2013-01-17 07:51 -0800
Re: python sys.stdout and C++ iostreams::cout Lie Ryan <lie.1296@gmail.com> - 2013-01-18 18:21 +1100
csiph-web