473,406 Members | 2,208 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,406 software developers and data experts.

How do I create a dynamic wrapper for another language?

I'm trying to embed python into an application that already contains a
scripting language. This scripting language contains thousands of
commands and I have the ability to query the script engine and get
syntax information regarding valid arguments and such.

Rather than writing explicate wrappers for each command (which will be
very time consuming), I would like to extend python by creating a module
that allows any function name to be executed with any number of keyword
arguments. I would then like to take the function name and keyword
arguments and pass these to the apps script engine in the format
required.

Is there any way to do this or any way to do something like this?

Thanks in advance for any suggestions that may be offered.

--Whitney.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBArX3bDc8M60vtLoURAgLjAJwLVOvQumPFlMTorRepaO 43AGUBqQCeMLOx
tM8ADgxlY4PPl14uO4gtNuA=
=It2R
-----END PGP SIGNATURE-----

Jul 18 '05 #1
3 2018
Whitney Battestilli wrote:
I'm trying to embed python into an application that already contains a
scripting language. This scripting language contains thousands of
commands and I have the ability to query the script engine and get
syntax information regarding valid arguments and such.

Rather than writing explicate wrappers for each command (which will be
very time consuming), I would like to extend python by creating a module
that allows any function name to be executed with any number of keyword
arguments.. I would then like to take the function name and keyword
arguments and pass these to the apps script engine in the format required.

Is there any way to do this or any way to do something like this?

Thanks in advance for any suggestions that may be offered.

--Whitney.

Maybe this will point you in the right direction:
http://www-cad.eecs.berkeley.edu/~pi...ptEDA/dst.html

Pad.
Jul 18 '05 #2
has
> Whitney Battestilli wrote:
I'm trying to embed python into an application that already contains a
scripting language. This scripting language contains thousands of
commands and I have the ability to query the script engine and get
syntax information regarding valid arguments and such.

Rather than writing explicate wrappers for each command (which will be
very time consuming), I would like to extend python by creating a module
that allows any function name to be executed with any number of keyword
arguments.. I would then like to take the function name and keyword
arguments and pass these to the apps script engine in the format required.

Is there any way to do this or any way to do something like this?


It's pretty easy using Python's introspection features to supply the
syntactic sugar. Simple example:

class _Callable:
def __init__(self, name):
self._name = name

def __call__(self, **args):
# [Do argument name checking, etc. here]
# [Dispatch command here]
print 'Sending command %r with arguments: %r' % (self._name,
args) # TEST

class Bridge:
def __getattr__(self, name):
# [Do command name checking here]
return _Callable(name)
bridge = Bridge()
bridge.foo(bar=1, baz=True) # -> Sending command 'foo' with arguments
{'baz': True, 'bar': 1}
Also see my Python-to-Apple Event Manager bridge for ideas and/or
code: http://freespace.virgin.net/hamish.s...appscript.html
Jul 18 '05 #3
Has,

Thanks! This is exactly what I was missing.

I appreciate everybody's suggestions and the loads of general good info
on this list. I'm going to be able to get back into python for a few
months ( after a few year break ). I'll try to lurk on the list and
pitch in.

Thanks again,
--Whitney.

On Fri, 2004-05-21 at 10:33, has wrote:
Whitney Battestilli wrote:
I'm trying to embed python into an application that already contains a
scripting language. This scripting language contains thousands of
commands and I have the ability to query the script engine and get
syntax information regarding valid arguments and such.

Rather than writing explicate wrappers for each command (which will be
very time consuming), I would like to extend python by creating a module
that allows any function name to be executed with any number of keyword
arguments.. I would then like to take the function name and keyword
arguments and pass these to the apps script engine in the format required.

Is there any way to do this or any way to do something like this?


It's pretty easy using Python's introspection features to supply the
syntactic sugar. Simple example:

class _Callable:
def __init__(self, name):
self._name = name

def __call__(self, **args):
# [Do argument name checking, etc. here]
# [Dispatch command here]
print 'Sending command %r with arguments: %r' % (self._name,
args) # TEST

class Bridge:
def __getattr__(self, name):
# [Do command name checking here]
return _Callable(name)


bridge = Bridge()
bridge.foo(bar=1, baz=True) # -> Sending command 'foo' with arguments
{'baz': True, 'bar': 1}


Also see my Python-to-Apple Event Manager bridge for ideas and/or
code: http://freespace.virgin.net/hamish.s...appscript.html



Whitney Battestilli
Cell: 919-949-0686
OpenPGP Public Key

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBAri6kDc8M60vtLoURAviDAJ42SXwnOigzSsQL01tmqX hTuG0TCgCeMGMm
KrWminUurzVC7Ui4FVAyYVY=
=Fuj/
-----END PGP SIGNATURE-----

Jul 18 '05 #4

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

Similar topics

15
by: Steve Richfield | last post by:
To All, First, some of your replies to me have been posted through DevelopersDex, and these are NOT posted on USENET for the world to see. DevelopersDex appears to be trying to hijack USENET,...
4
by: Bill Sun | last post by:
Hi, All I have a conventional question, How to create a 3 dimension array by C language. I see some declare like this: int *** array; int value; array = create3Darray(m,n,l);
15
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
14
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
18
by: squaretriangle | last post by:
Is it possible through some trickery, perhaps using the methods of stdarg, to pass a dynamic (unknown at compile time) number of arguments to a function? For example, I want to enumerate an array...
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
BarryA
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...
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
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...
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.