Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'causing': 0.04; 'cpython': 0.05; 'importing': 0.05; 'interpreter': 0.05; 'received:134': 0.05; 'context': 0.07; 'defines': 0.09; 'integers': 0.09; 'overwrite': 0.09; 'segfault.': 0.09; 'so?': 0.09; 'variables.': 0.09; 'python': 0.11; 'behave': 0.16; 'buggy': 0.16; 'caches': 0.16; 'constants.': 0.16; 'equal.': 0.16; 'language)': 0.16; "object's": 0.16; 'protecting': 0.16; 'subject:non': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'mechanism': 0.19; 'import': 0.22; 'aug': 0.22; 'header:User-Agent:1': 0.23; 'mon,': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'thus': 0.29; "doesn't": 0.30; 'statement': 0.30; 'code': 0.31; 'that.': 0.31; 'constant': 0.31; 'ctypes': 0.31; 'view.': 0.31; 'probably': 0.32; 'definition': 0.35; 'there': 0.35; 'subject:skip:d 10': 0.36; 'subject:?': 0.36; 'changing': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'name': 0.63; 'provide': 0.64; 'total': 0.65; 'yes': 0.68; 'safe': 0.72; 'protect': 0.79; 'idiot': 0.84; 'pardon': 0.84; 'preventing': 0.84; '2013': 0.98 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EACgHElKGuA9G/2dsb2JhbABbwz2BN4MYAQEEAXgGCwsYCRYPCQMCAQIBRRMGAgKIBgatPYgHkGcWg3wDl2SGFos/gx4 Date: Mon, 19 Aug 2013 13:54:43 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Importing variables non-deterministic? References: <520f9054$0$30000$c3e8da3$5496439d@news.astraweb.com> <5211C5BD.5040209@rece.vub.ac.be> <5211D464.5090303@rece.vub.ac.be> <5211DF6C.6030603@rece.vub.ac.be> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376913307 news.xs4all.nl 15870 [2001:888:2000:d::a6]:43210 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52687 Op 19-08-13 11:18, Chris Angelico schreef: > On Mon, Aug 19, 2013 at 10:03 AM, Antoon Pardon > 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.