Print String

Balaji balaji at email.arizona.edu
Tue Jun 1 14:13:29 EDT 2004


Hello Eveybody,

I have written a method which prints the prefix notation of any expression.

here is the method...

def PrintPrefix(expr):
		if expr.__class__==E:
			print expr.operator,
                        PrintPrefix(expr.left),
                        PrintPrefix(expr.right),
                 else:
                         print expr,

Now if i pass an expression to it like e1=x+y+z:

I call it by passing PrintPrefix(e1):
The output is ++xyz

now i want to store this in a string...

Can anyone help....

Balaji



More information about the Python-list mailing list