[newbie]How to write lines of code in stdout ( like ksh -x option)?

Quinn Dunkan quinn at quetzal.ugcs.caltech.edu
Tue Jan 23 02:24:28 EST 2001


On Sun, 21 Jan 2001 18:31:43 +0100, Pierre-Louis Gaucheron
<pilou_g at club-internet.fr> wrote:
>Thanks for the answer,
>but now how can I print the lines with their arguments evaluated, like in
>your example :
>"y = 10 * 2" instead of  "y  = x * 2" ?

That's trickier.  You'll have to parse the string...  the parser module might
help.  Or if you wanna wimp out, a re.search(s, r'\b(\w+)\b').findall() or
however the syntax goes might do.  Once you extract the variables you're
interested from the string, you can find their values in the frame object.

I'll let you do this one since I'm not at a python REPL right now :)



More information about the Python-list mailing list