Hello
I am writing a Windows application where I need to redirect stdin,
stdout and stderr from Python. to my application
Is it a simple way of do it ?
Has anyone done it using Winsock ? 4 38582
Jan Knop <no****@nospam.yes> writes: Hello
I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ?
import sys
sys.stdin, sys.stderr, sys.stdout = map(open, 'in.txt err.txt out.txt'.split(),
'r w w'.split())
'as
"Alexander Schmolck" <a.********@gmx.net> wrote in message news:yf*************@black132.ex.ac.uk... Jan Knop <no****@nospam.yes> writes:
Hello
I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ?
import sys sys.stdin, sys.stderr, sys.stdout = map(open, 'in.txt err.txt out.txt'.split(), 'r w w'.split())
That is why map should be deprecated asap ;)
sys.stdin = open("in.txt")
sys.stdout = open("out.txt","w")
sys.stderr = open("err.txt","w")
-- Serge
"Serge Orlov" <so********@pobox.ru> writes: "Alexander Schmolck" <a.********@gmx.net> wrote in message news:yf*************@black132.ex.ac.uk... Jan Knop <no****@nospam.yes> writes:
Hello
I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ?
import sys sys.stdin, sys.stderr, sys.stdout = map(open, 'in.txt err.txt out.txt'.split(), 'r w w'.split())
That is why map should be deprecated asap ;)
sys.stdin = open("in.txt") sys.stdout = open("out.txt","w") sys.stderr = open("err.txt","w")
The obfuscation in the above example was intended not to immediately overwhelm
the OP (who expected having to use some winsock thingy) with simplicitly and
clarity, but now you've spoilt it.
'as
On 24 Nov 2003 02:02:50 +0000, Alexander Schmolck <a.********@gmx.net>
wrote: "Serge Orlov" <so********@pobox.ru> writes:
"Alexander Schmolck" <a.********@gmx.net> wrote in message news:yf*************@black132.ex.ac.uk... > Jan Knop <no****@nospam.yes> writes: > > > Hello > > > > I am writing a Windows application where I need to redirect stdin, > > stdout and stderr from Python. to my application > > Is it a simple way of do it ? > > import sys > sys.stdin, sys.stderr, sys.stdout = map(open, 'in.txt err.txt out.txt'.split(), > 'r w w'.split())
That is why map should be deprecated asap ;)
sys.stdin = open("in.txt") sys.stdout = open("out.txt","w") sys.stderr = open("err.txt","w")
The obfuscation in the above example was intended not to immediately overwhelm the OP (who expected having to use some winsock thingy) with simplicitly and clarity, but now you've spoilt it.
'as
Hi
Actually that what I wat in the end is a method for subsclassing the
python stdio's into my application window. This means that Python runs
in background with all threes stdio streams redirected .
This is I believe somehow done in the Komodo program from
ActiveState
As far as I have found out You need to define a Input and output
class and imlement Read Readline , Write and WriteLine method in
these classes.
Otherwise it will be necessary to somehow capture the Stdin stdout
streams from python console and redirect them .
with regards
Jan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: calmar |
last post by:
Hi all,
I would like to use python for a replacement for some binutils. I would
like to be able to pipe things into python. Actually I would not like
writing a 'script' to handle the input, but...
|
by: David Douard |
last post by:
Hi everybody,
let me explain by problem:
I am working on an application which consists in a C++ dll (numeric
computations) and a Python IHM (Python/Tk), which must run under Linux and
win32. My...
|
by: Xah Lee |
last post by:
Python Doc Problem Example: os.system
Xah Lee, 2005-09
today i'm trying to use Python to call shell commands. e.g. in Perl
something like
output=qx(ls)
in Python i quickly located the...
|
by: todddeluca |
last post by:
I am posting code for calling almost any python function from php,
because it seems generally useful. Please feel free to suggest
improvements or tell me this has already been done better...
|
by: Fuzzyman |
last post by:
Hello,
I'm trying to redirect standard out in a single namespace.
I can replace sys.stdout with a custom object - but that affects all
namespaces.
There will be code running simultaneously...
|
by: Pierre Rouleau |
last post by:
Hi all,
I have a consistent test case where os.popen3() hangs in Windows. The
system hangs when retrieving the lines from the child process stdout.
I know there were several reports related to...
|
by: lovecreatesbea... |
last post by:
For example, in Bourne Shell both stdout and stderr can be re-directed
to /dev/null,
$ ./a.out 2>&1 /dev/null
then is there any difference still?
|
by: Lincoln Yeoh |
last post by:
Hi,
I've just started to learn python (I've been using perl for some years).
How do I redirect ALL stderr stuff to syslog, even stderr from
external programs that don't explicitly change their...
|
by: Gabriel Genellina |
last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com>
escribió:
Use subprocess.PIPE
Usually the tricky part is to figure out exactly whether there is more
input or not. With...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| | |