Skip to content

Commit

Permalink
Minor typo fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
petrushev committed Dec 6, 2012
1 parent b002ea0 commit ab1eeef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion magicmethods.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h4>The magic behind containers</h4>
<dt><code>__iter__(self)</code></dt>
<dd>Should return an iterator for the container. Iterators are returned in a number of contexts, most notably by the <code>iter()</code> built in function and when a container is looped over using the form <code>for x in container:</code>. Iterators are their own objects, and they also must define an <code>__iter__</code> method that returns <code>self</code>.</dd>
<dt><code>__reversed__(self)</code></dt>
<dd>Called to implement behavior for the <code>reversed()</code> built in function. Should return a reversed version of the sequence. Implement this only if the sequence class is ordered, like list of tuple.</dd>
<dd>Called to implement behavior for the <code>reversed()</code> built in function. Should return a reversed version of the sequence. Implement this only if the sequence class is ordered, like list or tuple.</dd>
<dt><code>__contains__(self, item)</code></dt>
<dd><code>__contains__</code> defines behavior for membership tests using <code>in</code> and <code>not in</code>. Why isn't this part of a sequence protocol, you ask? Because when <code>__contains__</code> isn't defined, Python just iterates over the sequence and returns <code>True</code> if it comes across the item it's looking for.</dd>
<dt><code>__missing__(self, key)</code></dt>
Expand Down
2 changes: 1 addition & 1 deletion magicmethods.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ Without any more wait, here are the magic methods that containers use:
: Should return an iterator for the container. Iterators are returned in a number of contexts, most notably by the `iter()` built in function and when a container is looped over using the form `for x in container:`. Iterators are their own objects, and they also must define an `__iter__` method that returns `self`.

`__reversed__(self)`
: Called to implement behavior for the `reversed()` built in function. Should return a reversed version of the sequence. Implement this only if the sequence class is ordered, like list of tuple.
: Called to implement behavior for the `reversed()` built in function. Should return a reversed version of the sequence. Implement this only if the sequence class is ordered, like list or tuple.

`__contains__(self, item)`
: `__contains__` defines behavior for membership tests using `in` and `not in`. Why isn't this part of a sequence protocol, you ask? Because when `__contains__` isn't defined, Python just iterates over the sequence and returns `True` if it comes across the item it's looking for.
Expand Down

0 comments on commit ab1eeef

Please sign in to comment.