I am debugging my program and I am confused as to why one of my statements is evaluating to false. I am checking if the second to last index in my array (which is a string) starts with '\' character. I am writing an interpreter for post script and so this helps me determine whether or not the user is defining a variable ex: \x. My if statement that is checking this for me is evaluating to false and I cannot figure out why. Any thoughts?
def psDef():
if(opstack[-2].startswith('\\')): # this is evaluating to false for some reason
name = opPop() #pop the name off the operand stack
value = opPop() #pop the value off the operand stack
define(name, value)
else:
print("Improper use of keyword: def")
def testLookup():
opPush("\n1")
opPush(3)
psDef()
if lookup("n1") != 3:
return False
return True