From 9dbe971cd1f186714ff61413e5a8138fd5cb1933 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sat, 20 Dec 2014 16:52:45 +0100 Subject: [PATCH] add __getitem__ and __setitem__ to Expression --- pymath/expression.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pymath/expression.py b/pymath/expression.py index e230ff0..f27478f 100644 --- a/pymath/expression.py +++ b/pymath/expression.py @@ -147,6 +147,15 @@ class Expression(object): return 0 return 1 + # ----------- + # Expression act as container from self.postfix_tokens + + def __getitem__(self, index): + return self.postfix_tokens[index] + + def __setitem__(self, index, value): + self.postfix_tokens[index] = value + # ----------- # Some math manipulations