argument list

Phil Hornby phil.hornby at accutest.co.uk
Mon Dec 29 17:04:29 EST 2003


>> I am working on a solution embedding Python in an app that will looks for
>> specific string combination within the function names to determine if a
>> handler for an event exists; I have been able to extract the function
names
>> and find all of the 'fields' of interest. What I am concerned about,
>> however, is that they could have the wrong argument profile, as specific
>> handlers will have specific function arguments - can I find out what
>> arguments a specific functions takes from the C-API? As I don't seem to
be
>> able to find anything...but I could be just being blind...
>[...]
>
>First, maybe what you really want is just the equivalent of
>func(*args, **kwds)?  (don't remember off the top of my head how to do
>that)
>
>Or maybe what you're missing is that you can just use different method
>naming conventions for different kinds of handler?

What I am doing is basically looking for a function with a name like:

def on_canmsg( id, dlc, data, time ):
	## catch all for CAN messages
	## do something

def on_canmsg_100( id, dlc, data, time):
	## message id 100 handler
	## do something different

Based on the function name I know that the first is a catch all for CAN
messages and the second is for handling a message with an identifier of 100.
The big BUT that I have is what if they define the functions like below:

def on_canmsg( a, b ):
	## catch all for CAN messages
	## incorrect arguments

Then when the function is called from the C-API it would not do as it
should. So what I want to do is to inspect the list of argument names, I
know I can't check what types the function composer uses/assumes but if I
can atleast check the names they use then I will have atleast some
confidence in the function being correct. I need to do this from the C-API
and would rather avoid having to call a script to check a script.

So any suggestions?

TIA

Phil






More information about the Python-list mailing list