sage: a[0:5]
[a0, a1, a2, a3, a4]
+ If for whatever reason you prefer square brackets, the following
+ also works::
+
+ sage: a = SymbolSequence('a')
+ sage: a[1,3]
+ a13
+
TESTS:
We shouldn't overwrite variables in the global namespace::
def __getitem__(self, key):
+ if isinstance(key, tuple):
+ return self(*key)
+
if isinstance(key, slice):
# We were given a slice. Clean up some of its properties
# first. The start/step are default for lists. We make
# If the user asks for a slice, we'll be returning a list
# of symbols.
return [ self(idx) for idx in range(start, key.stop, step) ]
- else:
- return self(key)
+
+ return self(key)
def __call__(self, *args):