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 2 2229
On 25 Jun 2004 12:11:48 GMT,
Bertram Scharpf <b.*******@tesi onmail.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
Hi Heather,
Heather Coppersmith <me@privacy.net > schrieb: On 25 Jun 2004 12:11:48 GMT, Bertram Scharpf <b.*******@tesi onmail.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 script to a
file (including that which is printed by the spawned programs) via the
redirect (">") function on a Win2K Command Prompt. In the captured
output however, the output from the os.system() calls ALWAYS comes
before the output from the...
|
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 the sale of at least 10 Alex
Martelli books. I am now in the fortunate position of being able to use
Python for a large project, and as such I have a question.
We are developing a distributed application running on approximately six
thousand...
|
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 client, or acting as a proxy.
I started with a modified version of TinyHTTPProxy postet by Suzuki
Hisao somewhere in 2003 to this list and tried to extend it to my needs.
It works quite well if I configure my client to use it, but using
iptables...
|
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 problem is the C++ lib does write stuffs on its stdout, and I
would like to print those messages in a Tk frame. When I run the
computation, it has it's own thread.
So my question is : how van I redirect the dll's stdout to something I can
|
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.
| |
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 that could import sys
afterwards - so I don't want to make the change in the sys module.
|
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 particular?
I'm thinking of running it on the Linksys's Linux-based open
source router WRT54G. It has 4MB flash and 16MB RAM. I think
another model has 16MB flash. Any possibilities of running
Python on these systems?
|
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):
return "bar";
sys.stdin = RedirectB();
|
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.
I want to be able to debug the Python script by using a debug server,
like Winpdb (winpdb.org).
I use ActivePython 2.5.2.2, Microsoft Visual Studio 2005, and Winpdb
1.3.8.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |