Out of a challenge for myself, I created this little program in which you can create "variables", test those "variable" values, test regular values, or clear all the "variables".
from operator import *
oper = {
"==": eq,
">": gt,
"<": lt,
"<=": le,
">=": ge,
"!=": one,}
var = []
def println(stringint):
print stringint
def clearvars():
del var[:]
def createvar(value):
var.append(value)
def returnbool(value1, testvalue, value2):
print testvalue(value1, value2)
Here's an example of an interpreter session. If you're curious, pcl
is the filename.
>>> import pcl
>>> pcl.createvar(1)
>>> pcl.createvar(3)
>>> pcl.println(pcl.var)
[1, 3]
>>> pcl.returnbool(pcl.var[0], pcl.oper["!="], pcl.var[1])
True
>>> pcl.clearvars()
>>> pcl.println(pcl.var)
[]
All I'm really looking for are places where I could improve on, and how I can make this compatible with Python2 & Python3.