473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Redirecting I/O in embedded Python

Hi,

in one of my C programs, I call embedded Python code. Now, I
would like to redirect stdin/stdout to strings I can assign
to/read out within the C code.

This should be a solvable problem creating modules that have
a member function 'write' or 'readline' respectively and
assigning them to sys.stdin and sys.stdout.

Before I do this work, I would like to ask if there is a
reported standard way to do it or if there is even the
finished code to be obtained anywhere on the web.

Thanks in advance,

Bertram

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
Jul 18 '05 #1
2 2218
On 25 Jun 2004 12:11:48 GMT,
Bertram Scharpf <b.*******@tesionmail.de> wrote:
Hi,
in one of my C programs, I call embedded Python code. Now, I
would like to redirect stdin/stdout to strings I can assign
to/read out within the C code. This should be a solvable problem creating modules that have
a member function 'write' or 'readline' respectively and
assigning them to sys.stdin and sys.stdout. Before I do this work, I would like to ask if there is a
reported standard way to do it or if there is even the
finished code to be obtained anywhere on the web.


Put the library reference under your pillow tonight, and read the
sections on stringio and cstringio in the morning.

Regards,
Heather

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
Jul 18 '05 #2
Hi Heather,

Heather Coppersmith <me@privacy.net> schrieb:
On 25 Jun 2004 12:11:48 GMT,
Bertram Scharpf <b.*******@tesionmail.de> wrote:
Hi,
in one of my C programs, I call embedded Python code. Now, I
would like to redirect stdin/stdout to strings I can assign
to/read out within the C code.

This should be a solvable problem creating modules that have
a member function 'write' or 'readline' respectively and
assigning them to sys.stdin and sys.stdout.

Before I do this work, I would like to ask if there is a
reported standard way to do it or if there is even the
finished code to be obtained anywhere on the web.


Put the library reference under your pillow tonight, and read the
sections on stringio and cstringio in the morning.


Yes, I did already think of that solution. But compared to
that mentioned above, it wouldn't be less effort in
programming for me, but rather a loss in efficiency I
suppose. (Additional modules would be loaded and strings
would be copied once more.)

Thank you, anyway.

Bertram

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Birch | last post by:
I have a python script that uses the print function throughout, and as well uses calls to os.system() to spawn DOS commandline executables. My issue is that I redirect all of the output from this...
13
by: Alexander May | last post by:
Hi, I love Python! I've been using it for a couple of years now and have found it to be a highly productive language. I evangelize it to my developer friends and am probably responsible for...
3
by: paul koelle | last post by:
Hi list, My ultimate goal is to have a small HTTP proxy which is able to show a message specific to clients name/ip/status then handle the original request normally either by redirecting the...
3
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...
3
by: Godzilla | last post by:
Has anyone install Python on Windows XP Embedded? We wish to evaluate the possible solution of installing Python with WinXPE on a PC/104 plus module. Thank you.
9
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...
20
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in...
1
by: andy | last post by:
Can anyone tell me what I am doing wrong with the following code? When python 2.4 is embedded it crashes because of the assignment to stdin. import sys; class RedirectB: def readline(self):...
4
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.