Skip to content

Commit

Permalink
Merge pull request #173 from gabycasper007/master
Browse files Browse the repository at this point in the history
Last __getitem__ example
  • Loading branch information
yasoob committed Sep 9, 2018
2 parents 3cf1eec + 3cae4cb commit e16804a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ Implementing **getitem** in a class allows its instances to use the []
def __getitem__(self,i):
return self.info[i]
foo = OldClass()
foo['title']
foo = GetTest()
foo['name']
# Output: 'Yasoob'
foo['number']
Expand All @@ -211,7 +211,7 @@ Without the ``__getitem__`` method we would have got this error:

.. code:: python
>>> foo['title']
>>> foo['name']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Expand Down

0 comments on commit e16804a

Please sign in to comment.