473,795 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)

iD8DBQBArX3bDc8 M60vtLoURAgLjAJ wLVOvQumPFlMTor RepaO43AGUBqQCe MLOx
tM8ADgxlY4PPl14 uO4gtNuA=
=It2R
-----END PGP SIGNATURE-----

Jul 18 '05 #1
3 2033
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__(sel f, 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__(sel f, 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)

iD8DBQBAri6kDc8 M60vtLoURAviDAJ 42SXwnOigzSsQL0 1tmqXhTuG0TCgCe MGMm
KrWminUurzVC7Ui 4FVAyYVY=
=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
3821
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, though there may be some more benign explanation that escapes me. If you want the world to see your replies, then you should post them directly to USENET. However, I'll see them either way. After years of frustration with DAO, it dawned on me...
4
4337
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
26518
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
1999
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 just trying to do this in phases to understand what's going on. I'm getting an error (Object doesn't support this property or method) in IE and I can't figure out what I'm doing wrong. Can anyone tell me? if (navigator.appName == "Microsoft...
7
8224
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
4662
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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3502
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- 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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
18
2603
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 of values and then pass them all to sprintf. I wouldn't want to write an explicit check for each amount of variables that I might want to send, nor write my own sprintf function that takes an array. Can it be done?
5
2587
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 algorithm to solve a certain messy problem, and many different things. For that I often use several general modules that I have written, like implementation of certain data structures, and small general "utility" functions/classes, plus of course...
0
9522
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,...
0
10448
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, 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...
0
10217
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 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...
1
10167
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,...
1
7544
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.