Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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; 'received:134': 0.05; 'context': 0.07; 'variables': 0.07; 'attributes': 0.09; 'defines': 0.09; 'iac': 0.09; 'sure,': 0.09; 'variable,': 0.09; 'variables.': 0.09; 'python': 0.11; 'buggy': 0.16; 'constants.': 0.16; 'enum': 0.16; 'fine.': 0.16; 'language)': 0.16; 'reasonable.': 0.16; 'subject:non': 0.16; 'variable.': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'meant': 0.20; 'seems': 0.21; '>>>': 0.22; 'example': 0.22; 'import': 0.22; '(in': 0.22; 'aug': 0.22; 'header :User-Agent:1': 0.23; 'case.': 0.24; 'instance,': 0.24; 'mon,': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'generally': 0.29; 'thus': 0.29; "doesn't": 0.30; 'statement': 0.30; 'code': 0.31; '>>>>': 0.31; 'constant': 0.31; 'class': 0.32; 'probably': 0.32; 'problem': 0.35; 'agree': 0.35; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'subject:skip:d 10': 0.36; 'subject:?': 0.36; 'changing': 0.37; 'too': 0.37; 'being': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'dave': 0.60; 'name': 0.63; 'more': 0.64; 'dont': 0.67; 'nobody': 0.68; 'pardon': 0.84; 'angel': 0.91; 'avoided.': 0.91; 'hand,': 0.93; '2013': 0.98 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EAC/eEVKGuA9G/2dsb2JhbABbgzzAA4E3gxgBAQV4EQsYCRYPCQMCAQIBRRMGAgKIDK1MiAeQZxaDfAOXZIEthGmLP4Me Date: Mon, 19 Aug 2013 11:03:40 +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> 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376903021 news.xs4all.nl 15894 [2001:888:2000:d::a6]:55405 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52680 Op 19-08-13 10:32, Chris Angelico schreef: > On Mon, Aug 19, 2013 at 9:16 AM, Antoon Pardon > wrote: >> Op 19-08-13 09:45, Dave Angel schreef: >>> Antoon Pardon wrote: >>>> I think you are overstating your case. Classes and functions are >>>> variables too and in general nobody seems to have a problem with them >>>> being global. >>>> >>> >>> It's global *variables* that are to be avoided. constants like clsases >>> and functions are fine. On the other hand, class attributes can be >>> variable, and thus are to be avoided when reasonable. >> >> Python has no constants. Classes and functions can be changed just like >> any other variable. I agree that classes and function are generally >> meant to be constant, but often enought so are global int variables. > > # telnet.py > IAC = 0xFF > GA = 0xF9 > WILL = 0xFB > WONT = 0xFC > DO = 0xFD > DONT = 0xFE > > > # connection.py > from telnet import IAC,DO,DONT > > > To be sure, Python won't stop me from changing the value of DONT. But > it's a constant, and its value is defined elsewhere (RFC 854). (In > this instance, an enum would probably be the better option; but this > is an example of a more general case.) 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. -- Antoon Pardon