summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-05-10 20:14:04 +0200
committerClaude Paroz <claude@2xlibre.net>2012-05-10 20:15:49 +0200
commit169b1a404c8118bb75840523d5fb3543de9c8889 (patch)
tree7d894e0ade3cb2fc7b8a6d33344bc3ac479a83c7 /docs
parent1c1a22963236c6015724bfbf43dd56dbe40a6cf9 (diff)
Replaced foo.next() by next(foo).
This new syntax for next() has been introduced in Python 2.6 and is compatible with Python 3.
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-template-tags.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index ffac791ae4..1d933fe3da 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -569,7 +569,7 @@ A naive implementation of ``CycleNode`` might look something like this:
def __init__(self, cyclevars):
self.cycle_iter = itertools.cycle(cyclevars)
def render(self, context):
- return self.cycle_iter.next()
+ return next(self.cycle_iter)
But, suppose we have two templates rendering the template snippet from above at
the same time:
@@ -603,7 +603,7 @@ Let's refactor our ``CycleNode`` implementation to use the ``render_context``:
if self not in context.render_context:
context.render_context[self] = itertools.cycle(self.cyclevars)
cycle_iter = context.render_context[self]
- return cycle_iter.next()
+ return next(cycle_iter)
Note that it's perfectly safe to store global information that will not change
throughout the life of the ``Node`` as an attribute. In the case of