subexprs = ['base', 'start', 'stop']
+ def infer_type(self, env):
+ base_type = self.base.infer_type(env)
+ if base_type.is_string:
+ return bytes_type
+ elif base_type in (bytes_type, str_type, unicode_type,
+ list_type, tuple_type):
+ return base_type
+ return py_object_type
+
def calculate_constant_result(self):
self.constant_result = self.base.constant_result[
self.start.constant_result : self.stop.constant_result]
B = bool()
assert typeof(B) == "bool object", typeof(B)
+def slicing():
+ """
+ >>> slicing()
+ """
+ b = b"abc"
+ assert typeof(b) == "char *", typeof(b)
+ b1 = b[1:2]
+ assert typeof(b1) == "bytes object", typeof(b1)
+ u = u"xyz"
+ assert typeof(u) == "unicode object", typeof(u)
+ u1 = u[1:2]
+ assert typeof(u1) == "unicode object", typeof(u1)
+ L = [1,2,3]
+ assert typeof(L) == "list object", typeof(L)
+ L1 = L[1:2]
+ assert typeof(L1) == "list object", typeof(L1)
+ t = (4,5,6)
+ assert typeof(t) == "tuple object", typeof(t)
+ t1 = t[1:2]
+ assert typeof(t1) == "tuple object", typeof(t1)
+
def multiple_assignments():
"""
>>> multiple_assignments()