Back to Bazel

Range

docs/versions/6.4.0/rules/lib/range.mdx

9.2.0814 B
Original Source
<html devsite> <head> <meta name="project_path" value="/_project.yaml"> <meta name="book_path" value="/versions/6.4.0/_book.yaml"> </head> <body> <h1 class="page-title" id="modules.range">range</h1> <!-- {% raw %} -->

A language built-in type to support ranges. Example of range literal:

<pre class=language-python>x = range(1, 10, 3)</pre>Accessing elements is possible using indexing (starts from <code>0</code>): <pre class=language-python>e = x[1] # e == 2</pre>Ranges do not support the <code>+</code> operator for concatenation.Similar to strings, ranges support slice operations:<pre class=language-python>range(10)[1:3] # range(1, 3)

range(10)[::2] # range(0, 10, 2) range(10)[3:0:-1] # range(3, 0, -1)</pre>Ranges are immutable, as in Python 3.

</body> </html> <!-- {% endraw %} -->