]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
docs: Python3-ize the examples 1010/head
authorDeepak Amin <dvamin@twosigma.com>
Fri, 31 May 2019 18:17:35 +0000 (14:17 -0400)
committerDeepak Amin <deepak.v.amin@gmail.com>
Fri, 31 May 2019 20:12:33 +0000 (16:12 -0400)
This commit updates the examples to conform to Python 3 instead
of Python 2, as Python 3 is more acceptable these days.

docs/api.rst
docs/templates.rst

index fedc1c73de553e37b1a0a6b38299df48f70e0836..a45d1c43aecd85388e707673514fcf10ad8a0abf 100644 (file)
@@ -46,7 +46,7 @@ To load a template from this environment you just have to call the
 
 To render it with some variables, just call the :meth:`render` method::
 
-    print template.render(the='variables', go='here')
+    print(template.render(the='variables', go='here'))
 
 Using a template loader rather than passing strings to :class:`Template`
 or :meth:`Environment.from_string` has multiple advantages.  Besides being
@@ -834,7 +834,7 @@ Here a simple test that checks if a variable is a prime number::
     def is_prime(n):
         if n == 2:
             return True
-        for i in xrange(2, int(math.ceil(math.sqrt(n))) + 1):
+        for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
             if n % i == 0:
                 return False
         return True
index d10d5e6729bb84811a1409ff4b6819e1c914836a..ec4ba81d62a95d78d430c27720a52ad473a43a63 100644 (file)
@@ -572,7 +572,7 @@ As variables in templates retain their object properties, it is possible to
 iterate over containers like `dict`::
 
     <dl>
-    {% for key, value in my_dict.iteritems() %}
+    {% for key, value in my_dict.items() %}
         <dt>{{ key|e }}</dt>
         <dd>{{ value|e }}</dd>
     {% endfor %}
@@ -1196,7 +1196,6 @@ but exists for completeness' sake.  The following operators are supported:
 /
     Divide two numbers.  The return value will be a floating point number.
     ``{{ 1 / 2 }}`` is ``{{ 0.5 }}``.
-    (Just like ``from __future__ import division``.)
 
 //
     Divide two numbers and return the truncated integer result.