Extending Python questions

Eli Daniel elie at flashmail.com
Wed Nov 3 12:30:41 EST 2004


Hi,
I am relative new to Python. Please tell me if the following is
possible.
I have a command line shell written in C. This shell executes some
commands which I would like to import to the python shell.
Here is an example command from my shell:

openconnection www.yahoo.com 12 2000

So I've created a dll (myshell_d.dll) according to the manual
("Extending Python with C or C++") and it works. The problem is the
syntax I have to use now is

myshell.openconnection('www.yahoo.com',12,2000)

It's not only the problem of comfort - it's a problem of changing
*some* scripts. And there's more than that - my shell functions
already know how to handle it's arguments (which's number may vary),
it doesn't need python to do that. All it needs is a pointer to a
string representing the arguments (in our case "www.yahoo.com 12
2000"). I've tried using PyArg_UnpackTuple but without success.

So I have two questions:
1. Is it possible to move the calls to a upper level (i.e. call
"openconnection" and  not "myshell.openconnection") ?
2. Is is possible to remove the brackets and commas? (i.e.
"www.yahoo.com 12 2000" instead of ('www.yahoo.com',12,2000)?

My final goal is to use the original commands if possible.
thanks in advance,
Eli



More information about the Python-list mailing list