Error: Variable x is read only
Stay organized with collections
Save and categorize content based on your preferences.
Report an issueopen_in_new
View sourceopen_in_new
Nightly
·
8.3
·
8.2
·
8.1
·
8.0
·
7.6
A global variable cannot be reassigned. It will always point to the same object.
However, its content might change, if the value is mutable (for example, the
content of a list). Local variables don't have this restriction.
a = [1, 2]
a[1] = 3
b = 3
b = 4 # forbidden
ERROR: /path/ext.bzl:7:1: Variable b is read only
You will get a similar error if you try to redefine a function (function
overloading is not supported), for example:
def foo(x): return x + 1
def foo(x, y): return x + y # forbidden
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-04 UTC.
[null,null,["Last updated 2025-07-04 UTC."],[],[],null,[]]