finding objects in a piece of functional code ?

CHEN Guang dr.cg at 126.com
Sun Apr 11 14:57:19 CEST 2010


PythoidC (http://pythoidc.googlecode.com or http://pythoidc.sf.net ) 
took the similar technique "finding objects in a piece of functional C code with Python"
In the thread "Re: braceless and semicolonless", I discussed some details. May be of some help. 


----- Original Message ----- 
From: Stef Mientki 
To: python-list at python.org 
Sent: Sunday, April 11, 2010 12:08 AM
Subject: finding objects in a piece of functional code ?


hello,

I would like to translate some functional description into some standard class object,
so it can be used as a basic building brick into a larger piece of code.

Suppose the functional description is:

Name = 'Test_Function'
Out = 3 * In

That's all I would like to write.
So it should be translated into something :

class Test_Function ( basic_buidling_brick ) :
    Orginal_Description = """
Name = 'Test_Function'
Out = 3 * In
    """
    def Run ( self, Inputs ) :
        Output = 3 * Input
        return Output

One of the tasks is to find all "objects" in the functional code.,
so the translator can ask additional information for input/output/memory variables.
The best I can think of is something like this:

>>> my={}
>>> my2=copy.copy(my)
>>> exec('A=3; B=4; C=A*B; print A,B,C',my)
3 4 12
>>> for item in my :
...   if item not in my2 :
...     print item
... 
__builtins__
A
C
B

But this doesn't work, if I use a not yet definied variable (like "In" in the example above).

Are there better ways ?

Or even better are there programs or libraries that can perfom such a translation ?

thanks,
Stef Mientki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100411/5d315cdf/attachment.html>


More information about the Python-list mailing list