Op 19-08-13 11:18, Chris Angelico schreef: > On Mon, Aug 19, 2013 at 10:03 AM, Antoon Pardon > <antoon.par...@rece.vub.ac.be> wrote: >> This is irrelevant. That some context defines a constant, and that you >> can use a variable with the same name as a constant in python, doesn't >> contradict the statement that python (as a language) doesn't has >> constants. There is nothing in the language that would prevent buggy >> code from changing any of those variables. So from a python point of >> views these are just global variables. Just as the struct_global.y was >> in the original contribution. > > And there's nothing preventing a program from using ctypes to > overwrite an object's refcount, thus causing a segfault. So?
Yes so? What is your point? Since Cpython caches small integers there is probably nothing preventing a program from using ctypes to make the number three behave as the number five. That doesn't mean that the language define three and five to be equal. A language having constants, does mean that the language can prevent a name from being reassigned. > The issue > was regarding imports, and it's perfectly safe to import a constant, > even if the interpreter doesn't protect you from then being a total > idiot and changing it. Python doesn't have constants, so you statement about importing a constant doesn't make sense. The point is that python doesn't provide the mechanism for protecting names against reassignments. So you don't know whether the variable you think of as a constant is so in reality. And this from a pure language definition point of view. That you can use tools that make the interpreter no longer behave as the language should, doesn't negate that. -- Antoon Pardon. -- http://mail.python.org/mailman/listinfo/python-list