docs/versions/8.3.0/rules/lib/globals/all.mdx
{% dynamic setvar source_file "NONE" %} {% dynamic setvar version "8.3.0" %} {% dynamic setvar original_path "/rules/lib/globals/all" %} {% include "_buttons.html" %}
<!-- {% raw %} -->Methods available in all Bazel files, including .bzl files, BUILD, MODULE.bazel, VENDOR.bazel, and WORKSPACE.
<h2>Members</h2> <ul> <li> <a href="#abs">abs</a> </li> <li> <a href="#all">all</a> </li> <li> <a href="#any">any</a> </li> <li> <a href="#bool">bool</a> </li> <li> <a href="#dict">dict</a> </li> <li> <a href="#dir">dir</a> </li> <li> <a href="#enumerate">enumerate</a> </li> <li> <a href="#fail">fail</a> </li> <li> <a href="#float">float</a> </li> <li> <a href="#getattr">getattr</a> </li> <li> <a href="#hasattr">hasattr</a> </li> <li> <a href="#hash">hash</a> </li> <li> <a href="#int">int</a> </li> <li> <a href="#len">len</a> </li> <li> <a href="#list">list</a> </li> <li> <a href="#max">max</a> </li> <li> <a href="#min">min</a> </li> <li> <a href="#print">print</a> </li> <li> <a href="#range">range</a> </li> <li> <a href="#repr">repr</a> </li> <li> <a href="#reversed">reversed</a> </li> <li> <a href="#set">set</a> </li> <li> <a href="#sorted">sorted</a> </li> <li> <a href="#str">str</a> </li> <li> <a href="#tuple">tuple</a> </li> <li> <a href="#type">type</a> </li> <li> <a href="#zip">zip</a> </li> </ul> <h2 id="abs">abs</h2>
<p><pre class="rule-signature">unknown abs(x)</pre></p>
Returns the absolute value of a number (a non-negative number with the same magnitude).<pre class="language-python">abs(-2.3) == 2.3</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="abs.x">
<code>x</code>
</td>
<td>
<a class="anchor" href="../core/int.html">int</a>; or <a class="anchor" href="../core/float.html">float</a>;
required
A number (int or float)
</td>
</tr>
</tbody>
</table>
<h2 id="all">all</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/bool.html">bool</a> all(elements)</pre></p>
Returns true if all elements evaluate to True or if the collection is empty. Elements are converted to boolean using the <a href="#bool">bool</a> function.<pre class="language-python">all(["hello", 3, True]) == True
all([-1, 0, 1]) == False</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="all.elements">
<code>elements</code>
</td>
<td>
required
A string or a collection of elements.
</td>
</tr>
</tbody>
</table>
<h2 id="any">any</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/bool.html">bool</a> any(elements)</pre></p>
Returns true if at least one element evaluates to True. Elements are converted to boolean using the <a href="#bool">bool</a> function.<pre class="language-python">any([-1, 0, 1]) == True
any([False, 0, ""]) == False</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="any.elements">
<code>elements</code>
</td>
<td>
required
A string or a collection of elements.
</td>
</tr>
</tbody>
</table>
<h2 id="bool">bool</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/bool.html">bool</a> bool(x=False)</pre></p>
Constructor for the bool type. It returns <code>False</code> if the object is <code>None</code>, <code>False</code>, an empty string (<code>""</code>), the number <code>0</code>, or an empty collection (e.g. <code>()</code>, <code>[]</code>). Otherwise, it returns <code>True</code>.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="bool.x">
<code>x</code>
</td>
<td>
default is <code>False</code>
The variable to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="dict">dict</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/dict.html">dict</a> dict(pairs=[], **kwargs)</pre></p>
Creates a <a href="../core/dict.html">dictionary</a> from an optional positional argument and an optional set of keyword arguments. In the case where the same key is given multiple times, the last value will be used. Entries supplied via keyword arguments are considered to come after entries supplied via the positional argument.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="dict.pairs">
<code>pairs</code>
</td>
<td>
default is <code>[]</code>
A dict, or an iterable whose elements are each of length 2 (key, value).
</td>
</tr>
<tr>
<td id="dict.kwargs">
<code>kwargs</code>
</td>
<td>
required
Dictionary of additional entries.
</td>
</tr>
</tbody>
</table>
<h2 id="dir">dir</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> dir(x)</pre></p>
Returns a list of strings: the names of the attributes and methods of the parameter object.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="dir.x">
<code>x</code>
</td>
<td>
required
The object to check.
</td>
</tr>
</tbody>
</table>
<h2 id="enumerate">enumerate</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> enumerate(list, start=0)</pre></p>
Returns a list of pairs (two-element tuples), with the index (int) and the item from the input sequence.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="enumerate.list">
<code>list</code>
</td>
<td>
required
input sequence.
</td>
</tr>
<tr>
<td id="enumerate.start">
<code>start</code>
</td>
<td>
<a class="anchor" href="../core/int.html">int</a>;
default is <code>0</code>
start index.
</td>
</tr>
</tbody>
</table>
<h2 id="fail">fail</h2>
<p><pre class="rule-signature"><code>None</code> fail(msg=None, attr=None, sep=" ", *args)</pre></p>
Causes execution to fail with an error.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="fail.msg">
<code>msg</code>
</td>
<td>
default is <code>None</code>
Deprecated: use positional arguments instead. This argument acts like an implicit leading positional argument.
</td>
</tr>
<tr>
<td id="fail.attr">
<code>attr</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>; or <code>None</code>;
default is <code>None</code>
Deprecated. Causes an optional prefix containing this string to be added to the error message.
</td>
</tr>
<tr>
<td id="fail.sep">
<code>sep</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
default is <code>" "</code>
The separator string between the objects, default is space (" ").
</td>
</tr>
<tr>
<td id="fail.args">
<code>args</code>
</td>
<td>
required
A list of values, formatted with debugPrint (which is equivalent to str by default) and joined with sep (defaults to " "), that appear in the error message.
</td>
</tr>
</tbody>
</table>
<h2 id="float">float</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/float.html">float</a> float(x=unbound)</pre></p>
Returns x as a float value. <ul><li>If <code>x</code> is already a float, <code>float</code> returns it unchanged. <li>If <code>x</code> is a bool, <code>float</code> returns 1.0 for True and 0.0 for False. <li>If <code>x</code> is an int, <code>float</code> returns the nearest finite floating-point value to x, or an error if the magnitude is too large. <li>If <code>x</code> is a string, it must be a valid floating-point literal, or be equal (ignoring case) to <code>NaN</code>, <code>Inf</code>, or <code>Infinity</code>, optionally preceded by a <code>+</code> or <code>-</code> sign. </ul>Any other value causes an error. With no argument, <code>float()</code> returns 0.0.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="float.x">
<code>x</code>
</td>
<td>
default is <code>unbound</code>
The value to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="getattr">getattr</h2>
<p><pre class="rule-signature">unknown getattr(x, name, default=unbound)</pre></p>
Returns the struct's field of the given name if it exists. If not, it either returns <code>default</code> (if specified) or raises an error. <code>getattr(x, "foobar")</code> is equivalent to <code>x.foobar</code>.<pre class="language-python">getattr(ctx.attr, "myattr")
getattr(ctx.attr, "myattr", "mydefault")</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="getattr.x">
<code>x</code>
</td>
<td>
required
The struct whose attribute is accessed.
</td>
</tr>
<tr>
<td id="getattr.name">
<code>name</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
The name of the struct attribute.
</td>
</tr>
<tr>
<td id="getattr.default">
<code>default</code>
</td>
<td>
default is <code>unbound</code>
The default value to return in case the struct doesn't have an attribute of the given name.
</td>
</tr>
</tbody>
</table>
<h2 id="hasattr">hasattr</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/bool.html">bool</a> hasattr(x, name)</pre></p>
Returns True if the object <code>x</code> has an attribute or method of the given <code>name</code>, otherwise False. Example:
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="hasattr.x">
<code>x</code>
</td>
<td>
required
The object to check.
</td>
</tr>
<tr>
<td id="hasattr.name">
<code>name</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
The name of the attribute.
</td>
</tr>
</tbody>
</table>
<h2 id="hash">hash</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/int.html">int</a> hash(value)</pre></p>
Return a hash value for a string. This is computed deterministically using the same algorithm as Java's <code>String.hashCode()</code>, namely: <pre class="language-python">s[0] * (31^(n-1)) + s[1] * (31^(n-2)) + ... + s[n-1]</pre> Hashing of values besides strings is not currently supported.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="hash.value">
<code>value</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
String value to hash.
</td>
</tr>
</tbody>
</table>
<h2 id="int">int</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/int.html">int</a> int(x, base=unbound)</pre></p>
Returns x as an int value.<ul><li>If <code>x</code> is already an int, <code>int</code> returns it unchanged.<li>If <code>x</code> is a bool, <code>int</code> returns 1 for True and 0 for False.<li>If <code>x</code> is a string, it must have the format <code><sign><prefix><digits></code>. <code><sign></code> is either <code>"+"</code>, <code>"-"</code>, or empty (interpreted as positive). <code><digits></code> are a sequence of digits from 0 up to <code>base</code> - 1, where the letters a-z (or equivalently, A-Z) are used as digits for 10-35. In the case where <code>base</code> is 2/8/16, <code><prefix></code> is optional and may be 0b/0o/0x (or equivalently, 0B/0O/0X) respectively; if the <code>base</code> is any other value besides these bases or the special value 0, the prefix must be empty. In the case where <code>base</code> is 0, the string is interpreted as an integer literal, in the sense that one of the bases 2/8/10/16 is chosen depending on which prefix if any is used. If <code>base</code> is 0, no prefix is used, and there is more than one digit, the leading digit cannot be 0; this is to avoid confusion between octal and decimal. The magnitude of the number represented by the string must be within the allowed range for the int type.<li>If <code>x</code> is a float, <code>int</code> returns the integer value of the float, rounding towards zero. It is an error if x is non-finite (NaN or infinity).</ul>This function fails if <code>x</code> is any other type, or if the value is a string not satisfying the above format. Unlike Python's <code>int</code> function, this function does not allow zero arguments, and does not allow extraneous whitespace for string arguments.<p>Examples:<pre class="language-python">int("123") == 123
int("-123") == -123 int("+123") == 123 int("FF", 16) == 255 int("0xFF", 16) == 255 int("10", 0) == 10 int("-0x10", 0) == -16 int("-0x10", 0) == -16 int("123.456") == 123 </pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="int.x">
<code>x</code>
</td>
<td>
required
The string to convert.
</td>
</tr>
<tr>
<td id="int.base">
<code>base</code>
</td>
<td>
default is <code>unbound</code>
The base used to interpret a string value; defaults to 10. Must be between 2 and 36 (inclusive), or 0 to detect the base as if <code>x</code> were an integer literal. This parameter must not be supplied if the value is not a string.
</td>
</tr>
</tbody>
</table>
<h2 id="len">len</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/int.html">int</a> len(x)</pre></p>
Returns the length of a string, sequence (such as a list or tuple), dict, set, or other iterable.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="len.x">
<code>x</code>
</td>
<td>
required
The value whose length to report.
</td>
</tr>
</tbody>
</table>
<h2 id="list">list</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> list(x=[])</pre></p>
Returns a new list with the same elements as the given iterable value.<pre class="language-python">list([1, 2]) == [1, 2]
list((2, 3, 2)) == [2, 3, 2] list({5: "a", 2: "b", 4: "c"}) == [5, 2, 4]</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="list.x">
<code>x</code>
</td>
<td>
iterable;
default is <code>[]</code>
The object to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="max">max</h2>
<p><pre class="rule-signature">unknown max(key=None, *args)</pre></p>
Returns the largest one of all given arguments. If only one positional argument is provided, it must be a non-empty iterable.It is an error if elements are not comparable (for example int with string), or if no arguments are given.<pre class="language-python">
max(2, 5, 4) == 5 max([5, 6, 3]) == 6 max("two", "three", "four", key = len) =="three" # the longest max([1, -1, -2, 2], key = abs) == -2 # the first encountered with maximal key value </pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="max.key">
<code>key</code>
</td>
<td>
callable; or <code>None</code>;
default is <code>None</code>
An optional function applied to each element before comparison.
</td>
</tr>
<tr>
<td id="max.args">
<code>args</code>
</td>
<td>
required
The elements to be checked.
</td>
</tr>
</tbody>
</table>
<h2 id="min">min</h2>
<p><pre class="rule-signature">unknown min(key=None, *args)</pre></p>
Returns the smallest one of all given arguments. If only one positional argument is provided, it must be a non-empty iterable. It is an error if elements are not comparable (for example int with string), or if no arguments are given.<pre class="language-python">
min(2, 5, 4) == 2 min([5, 6, 3]) == 3 min("six", "three", "four", key = len) == "six" # the shortest min([2, -2, -1, 1], key = abs) == -1 # the first encountered with minimal key value </pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="min.key">
<code>key</code>
</td>
<td>
callable; or <code>None</code>;
default is <code>None</code>
An optional function applied to each element before comparison.
</td>
</tr>
<tr>
<td id="min.args">
<code>args</code>
</td>
<td>
required
The elements to be checked.
</td>
</tr>
</tbody>
</table>
<h2 id="print">print</h2>
<p><pre class="rule-signature"><code>None</code> print(sep=" ", *args)</pre></p>
Prints <code>args</code> as debug output. It will be prefixed with the string <code>"DEBUG"</code> and the location (file and line number) of this call. The exact way in which the arguments are converted to strings is unspecified and may change at any time. In particular, it may be different from (and more detailed than) the formatting done by <a href='#str'><code>str()</code></a> and <a href='#repr'><code>repr()</code></a>.<p>Using <code>print</code> in production code is discouraged due to the spam it creates for users. For deprecations, prefer a hard error using <a href="#fail"><code>fail()</code></a> whenever possible.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="print.sep">
<code>sep</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
default is <code>" "</code>
The separator string between the objects, default is space (" ").
</td>
</tr>
<tr>
<td id="print.args">
<code>args</code>
</td>
<td>
required
The objects to print.
</td>
</tr>
</tbody>
</table>
<h2 id="range">range</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">sequence</a> range(start_or_stop, stop_or_none=None, step=1)</pre></p>
Creates a list where items go from <code>start</code> to <code>stop</code>, using a <code>step</code> increment. If a single argument is provided, items will range from 0 to that element.<pre class="language-python">range(4) == [0, 1, 2, 3]
range(3, 9, 2) == [3, 5, 7] range(3, 0, -1) == [3, 2, 1]</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="range.start_or_stop">
<code>start_or_stop</code>
</td>
<td>
<a class="anchor" href="../core/int.html">int</a>;
required
Value of the start element if stop is provided, otherwise value of stop and the actual start is 0
</td>
</tr>
<tr>
<td id="range.stop_or_none">
<code>stop_or_none</code>
</td>
<td>
<a class="anchor" href="../core/int.html">int</a>; or <code>None</code>;
default is <code>None</code>
optional index of the first item <i>not</i> to be included in the resulting list; generation of the list stops before <code>stop</code> is reached.
</td>
</tr>
<tr>
<td id="range.step">
<code>step</code>
</td>
<td>
<a class="anchor" href="../core/int.html">int</a>;
default is <code>1</code>
The increment (default is 1). It may be negative.
</td>
</tr>
</tbody>
</table>
<h2 id="repr">repr</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> repr(x)</pre></p>
Converts any object to a string representation. This is useful for debugging.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="repr.x">
<code>x</code>
</td>
<td>
required
The object to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="reversed">reversed</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> reversed(sequence)</pre></p>
Returns a new, unfrozen list that contains the elements of the original iterable sequence in reversed order.<pre class="language-python">reversed([3, 5, 4]) == [4, 5, 3]</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="reversed.sequence">
<code>sequence</code>
</td>
<td>
iterable;
required
The iterable sequence (e.g. list) to be reversed.
</td>
</tr>
</tbody>
</table>
<h2 id="set">set</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/set.html">set</a> set(elements=[])</pre></p>
Creates a new <a href="../core/set.html">set</a> containing the unique elements of a given
iterable, preserving iteration order.
<p>If called with no argument, <code>set()</code> returns a new empty set. <p>For example, <pre class=language-python> set() # an empty set set([3, 1, 1, 2]) # set([3, 1, 2]), a set of three elements set({"k1": "v1", "k2": "v2"}) # set(["k1", "k2"]), a set of two elements </pre> <!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="set.elements">
<code>elements</code>
</td>
<td>
default is <code>[]</code>
A set, a sequence of hashable values, or a dict.
</td>
</tr>
</tbody>
</table>
<h2 id="sorted">sorted</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> sorted(iterable, key=None, *, reverse=False)</pre></p>
Returns a new sorted list containing all the elements of the supplied iterable sequence. An error may occur if any pair of elements x, y may not be compared using x < y. The elements are sorted into ascending order, unless the reverse argument is True, in which case the order is descending.
Sorting is stable: elements that compare equal retain their original relative order.
<pre class="language-python"> sorted([3, 5, 4]) == [3, 4, 5] sorted([3, 5, 4], reverse = True) == [5, 4, 3] sorted(["two", "three", "four"], key = len) == ["two", "four", "three"] # sort by length </pre> <!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="sorted.iterable">
<code>iterable</code>
</td>
<td>
iterable;
required
The iterable sequence to sort.
</td>
</tr>
<tr>
<td id="sorted.key">
<code>key</code>
</td>
<td>
callable; or <code>None</code>;
default is <code>None</code>
An optional function applied to each element before comparison.
</td>
</tr>
<tr>
<td id="sorted.reverse">
<code>reverse</code>
</td>
<td>
<a class="anchor" href="../core/bool.html">bool</a>;
default is <code>False</code>
Return results in descending order.
</td>
</tr>
</tbody>
</table>
<h2 id="str">str</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> str(x)</pre></p>
Converts any object to string. This is useful for debugging.<pre class="language-python">str("ab") == "ab"
str(8) == "8"</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="str.x">
<code>x</code>
</td>
<td>
required
The object to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="tuple">tuple</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/tuple.html">tuple</a> tuple(x=())</pre></p>
Returns a tuple with the same elements as the given iterable value.<pre class="language-python">tuple([1, 2]) == (1, 2)
tuple((2, 3, 2)) == (2, 3, 2) tuple({5: "a", 2: "b", 4: "c"}) == (5, 2, 4)</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="tuple.x">
<code>x</code>
</td>
<td>
iterable;
default is <code>()</code>
The object to convert.
</td>
</tr>
</tbody>
</table>
<h2 id="type">type</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> type(x)</pre></p>
Returns the type name of its argument. This is useful for debugging and type-checking. Examples:<pre class="language-python">type(2) == "int"
type([1]) == "list" type(struct(a = 2)) == "struct"</pre>This function might change in the future. To write Python-compatible code and be future-proof, use it only to compare return values: <pre class="language-python">if type(x) == type([]): # if x is a list</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="type.x">
<code>x</code>
</td>
<td>
required
The object to check type of.
</td>
</tr>
</tbody>
</table>
<h2 id="zip">zip</h2>
<p><pre class="rule-signature"><a class="anchor" href="../core/list.html">list</a> zip(*args)</pre></p>
Returns a <code>list</code> of <code>tuple</code>s, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The list has the size of the shortest input. With a single iterable argument, it returns a list of 1-tuples. With no arguments, it returns an empty list. Examples:<pre class="language-python">zip() # == []
zip([1, 2]) # == [(1,), (2,)] zip([1, 2], [3, 4]) # == [(1, 3), (2, 4)] zip([1, 2], [3, 4, 5]) # == [(1, 3), (2, 4)]</pre>
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="zip.args">
<code>args</code>
</td>
<td>
required
lists to zip.
</td>
</tr>
</tbody>
</table>