aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDeepak Amin <dvamin@twosigma.com>2019-05-31 14:17:35 -0400
committerDeepak Amin <deepak.v.amin@gmail.com>2019-05-31 16:12:33 -0400
commit4965facc02a3c8db4a928efe33bdcbe5c7bb74e2 (patch)
tree293bb9c0ab4462177e9b92a17bca1222160cf316 /docs
parent67e2542dd496f81852e67681a2f9f744fab17bca (diff)
downloadjinja-4965facc02a3c8db4a928efe33bdcbe5c7bb74e2.tar.gz
docs: Python3-ize the examples
This commit updates the examples to conform to Python 3 instead of Python 2, as Python 3 is more acceptable these days.
Diffstat (limited to 'docs')
-rw-r--r--docs/api.rst4
-rw-r--r--docs/templates.rst3
2 files changed, 3 insertions, 4 deletions
diff --git a/docs/api.rst b/docs/api.rst
index fedc1c73..a45d1c43 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -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
diff --git a/docs/templates.rst b/docs/templates.rst
index d10d5e67..ec4ba81d 100644
--- a/docs/templates.rst
+++ b/docs/templates.rst
@@ -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.