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 38700
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |