-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuples.py
34 lines (25 loc) · 975 Bytes
/
tuples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from expressions_base import Expr
from objects import Object
from ranges import Subscriptable
class TupleExpression(Expr):
def __init__(self, contents):
self.contents = contents
def Eval(self, context, sub_value):
print "wah"
evaled_contents = [v.Eval(context) for v in self.contents]
return Tuple(evaled_contents)
class Tuple(Subscriptable):
def __init__(self, contents):
import proto_functions
Object.__init__(self, prototype=proto_functions.tuple_proto)
self.contents = contents
def __add__(self, other):
return Tuple(self.contents + other.contents)
def SetSlice(self, lindex, rindex, val):
raise TypeError('Tuples are immutable')
def GetIndex(self, index):
return self.contents[index]
def SetIndex(self, index, value):
raise TypeError('Tuples are immutable')
def __str__(self):
return '(%s)' % (', '.join([str(s) for s in self.contents]),)