finding objects in a piece of functional code ?

Stef Mientki stef.mientki at gmail.com
Sat Apr 10 12:08:25 EDT 2010


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/20100410/c91e19e9/attachment.html>


More information about the Python-list mailing list