+ def _subscript_integer_(self, n):
+ """
+ The subscript is a single integer, or something that acts like
+ one.
+ """
+ if n < 0:
+ # Cowardly refuse to create a variable named "a-1".
+ raise IndexError('Indices must be nonnegative')
+
+ try:
+ return self._symbols[n]
+ except KeyError:
+ self._symbols[n] = self._create_symbol_(n)
+ return self._symbols[n]
+
+
+ def _subscript_slice_(self, s):
+ """
+ We were given a slice. Clean up some of its properties
+ first. The start/step are default for lists. We make
+ copies of these because they're read-only.
+ """
+ (start, step) = (s.start, s.step)
+ if start is None:
+ start = 0
+ if s.stop is None:
+ # Would otherwise loop forever since our "length" is
+ # undefined.
+ raise ValueError('You must supply an terminal index')
+ if step is None:
+ step = 1
+
+ # If the user asks for a slice, we'll be returning a list
+ # of symbols.
+ return [ self._subscript_integer_(idx)
+ for idx in range(start, s.stop, step) ]