Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #26704: Add doctests for __getitem__.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Klein committed Nov 22, 2018
1 parent 9cae5bb commit 34c80dc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sage/databases/oeis.py
Expand Up @@ -1833,6 +1833,19 @@ def __getslice__(self, i, j):
return self.__getitem__(slice(i, j))

def __getitem__(self, x):
r"""
If ``x`` is a slice return the corresponding sub FancyTuple,
else return the `̀`x``-th item of ``self``.
TESTS::
sage: from sage.databases.oeis import FancyTuple
sage: t = ('é', 'è', 'à', 'ç')
sage: ft = FancyTuple(t)
sage: ft[0]
'é'
sage: ft[-1]
'ç'
"""
res = tuple.__getitem__(self, x)
if isinstance(res, tuple):
res = FancyTuple(res)
Expand Down

0 comments on commit 34c80dc

Please sign in to comment.