Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36948
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-01-17 07:51 -0800 |
| References | <2699150a-cf67-46ac-b863-34c92bffceaf@googlegroups.com> <mailman.592.1358437352.2939.python-list@python.org> |
| Subject | Re: python sys.stdout and C++ iostreams::cout |
| From | Utpal Sarkar <doetoe@gmail.com> |
| Message-ID | <mailman.593.1358437912.2939.python-list@python.org> (permalink) |
Thanks a lot Chris and Nobody! I'll have a look at dup2 for a start. > > 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