All pastes #388808 Raw Edit

Someone

public python v1 · immutable
·published 2007-03-10 09:15 UTC
rendered paste body
from string import *class postfixCalc:	"""basic postfix calculator"""	def __init__(self):		print "Welcome to the PostFix expression calculator v0.1"		self.eStack = []		self.getExpression();	def getExpression(self):		self.expression = raw_input("Enter expression:: ")		self.processExpression(self.expression)			def addOp(x, y):		self.eStack.append(x+y)			def subOp(x, y):		self.eStack.append(x-y)			def mulOp(x, y):		self.eStack.append(x*y)			def divOp(x, y):		self.eStack.append(x/y)			def modOp(x, y):		self.eStack.appent(x % y)	def processExpression(self, e):		t = split(e)		x = 0		ops = ['+','-','*','/','%']		while t[x] != '=':			if t[x] in ops:				switch = { '+': self.addOp,							'-': self.subOp,							'*': self.mulOp,							'/': self.divOp,							'%': self.modOp                          }				funct = switch.get(t[x])				#print self.eStack.pop() <--this is printing 2 things				funct(self.eStack.pop(), self.eStack.pop())			else:				self.eStack.append(t[x])							x = x+1						print self.eStack.pop()		pCalc = postfixCalc()