<P><FONT size="4">PythoidC (<A href="http://pythoidc.googlecode.com">http://pythoidc.googlecode.com</A> or <A href="http://pythoidc.sf.net">http://pythoidc.sf.net</A> ) <BR>took the similar technique "finding objects in a piece of functional C code with Python"<BR>In the thread "<FONT size="3">Re: braceless and semicolonless</FONT>", I discussed some details. May be of some help. </FONT></P>
<DIV><BR>----- Original Message ----- <BR>From: Stef Mientki <BR>To: python-list@python.org <BR>Sent: Sunday, April 11, 2010 12:08 AM<BR>Subject: finding objects in a piece of functional code ?<BR><BR><BR>hello,<BR><BR>I would like to translate some functional description into some standard class object,<BR>so it can be used as a basic building brick into a larger piece of code.<BR><BR>Suppose the functional description is:<BR><BR>Name = 'Test_Function'<BR>Out = 3 * In<BR><BR>That's all I would like to write.<BR>So it should be translated into something :<BR><BR>class Test_Function ( basic_buidling_brick ) :<BR>    Orginal_Description = """<BR>Name = 'Test_Function'<BR>Out = 3 * In<BR>    """<BR>    def Run ( self, Inputs ) :<BR>        Output = 3 * Input<BR>        return Output<BR><BR>One of the tasks is to find all "objects" in the functional code.,<BR>so the translator can ask additional information for input/output/memory variables.<BR>The best I can think of is something like this:<BR><BR>>>> my={}<BR>>>> my2=copy.copy(my)<BR>>>> exec('A=3; B=4; C=A*B; print A,B,C',my)<BR>3 4 12<BR>>>> for item in my :<BR>...   if item not in my2 :<BR>...     print item<BR>... <BR>__builtins__<BR>A<BR>C<BR>B<BR><BR>But this doesn't work, if I use a not yet definied variable (like "In" in the example above).<BR><BR>Are there better ways ?<BR><BR>Or even better are there programs or libraries that can perfom such a translation ?<BR><BR>thanks,<BR>Stef Mientki<BR></DIV><br><br><span title="neteasefooter"/></span>