"Constant variables" is a contradiction in terms. If it is constant, it cannot be a variable, and vice versa. Can we be more precise in the language used please?
We have two independent concepts here:
* name bindings: names can be bound to a value, or unbound with the `del` statement;
* values can be mutable or immutable.
"Constant" might refer to immutability. `1` is a constant, but `` is not, because the list can be mutated. In some languages (not Python), we can "freeze" a mutable object and turn it immutable.
Or it might refer to bindings: a perhaps a constant name cannot be unbound or rebound to a new object, but the object may be either mutable or immutable.
Can you explain what combination of these three features (binding of names, mutability of objects, a "freeze" protocol) you are looking for?
Usually if we have a constant we don't create another reference to it. So do not support two references. Why not? Many reasons, especially deallocation problems.
That seems very odd. That would mean that you can't pass constants to functions, or put them in lists or dicts, since that would create new references to the object.
What if an object has already got more than one reference?
>>> import gc >>> count = len(gc.get_referrers(None)) >>> print(count) 1771
With more than 1700 references to the None object, I guess we can't create a constant None. That's going to go straight into the list of Python WTFs. Small ints also have many references:
>>> len(gc.get_referrers(1)) 65
I think people would be surprised if they can't make a constant 1. I know I would be.