Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; 'else:': 0.03; 'syntax': 0.04; 'subject:Python': 0.06; 'builtin': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pythonic': 0.16; 'rather,': 0.16; 'statement.': 0.16; 'subject:variable': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'possible,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'follows': 0.31; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'being': 0.38; 'convention': 0.38; 'how': 0.40; 'subject:Can': 0.60; 'truly': 0.60; 'kind': 0.63; 'connecting': 0.64; 'mar': 0.68; 'useful.': 0.68; 'change?': 0.84; 'connected:': 0.84; 'technically': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=6ftmLhgDaZZjiyS/Xso3OaNMCMnlml23RbXMKFXi0jc=; b=XofNOU+sgJMMGzu4TEIq467B3MveCxep32+deoANi1BMVj2kJ0JXJX4eZETBfYjB2y tkZ0OwowJm/irhSQNdCAQo+6o9hcWTe5vil8tEpc8iEifeNcCqRKhwkwEmH8dpeWGWL3 uRbnG5Fs850NtkjqJBAZk2ovwv0l+JAXs3av7ijeG8uDX0wVExvo2wN8H0lvNHRhQUS/ YbVFjzd8CaYpvnHg5Y9vu9xEUhP3kGpvw7u8+swbj4xvFXYyEs1O+EJG4mtdhlRWUfoN NryD+vdxOpsMscjMpikC26lqxHSBs30L/xKUf4uFgcy5kWcbTiuGlN/GU2FEQzlQheBI SkzQ== MIME-Version: 1.0 X-Received: by 10.68.197.36 with SMTP id ir4mr3981040pbc.46.1393598253513; Fri, 28 Feb 2014 06:37:33 -0800 (PST) In-Reply-To: <87d2i7wbxs.fsf@elektro.pacujo.net> References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <5f4f5a5f-327a-4616-8235-17ee9e74c488@googlegroups.com> <530fef58$0$11113$c3e8da3@news.astraweb.com> <871tynznpd.fsf@elektro.pacujo.net> <53104798$0$11113$c3e8da3@news.astraweb.com> <87ha7jy2qs.fsf@elektro.pacujo.net> <87y50vwjq4.fsf@elektro.pacujo.net> <87d2i7wbxs.fsf@elektro.pacujo.net> Date: Sat, 1 Mar 2014 01:37:33 +1100 Subject: Re: Can global variable be passed into Python function? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393598262 news.xs4all.nl 2968 [2001:888:2000:d::a6]:55177 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67224 On Sat, Mar 1, 2014 at 1:26 AM, Marko Rauhamaa wrote: > Python isn't "averse" to the switch statement because it would be not > that useful. Rather, the problem is that Python doesn't have nonliteral > constants (scheme has builtin symbols). It is difficult to come up with > truly Pythonic syntax for the switch statement. > > Something like > > switch self.state from Connection.State: > case CONNECTING or CONNECTED: > ... > case DISONNECTING: > ... > else: > ... > > would be possible, but here, "Connection.State" is evaluated at compile > time. Don't know if there are any precedents to that kind of thing in > Python. Can you elaborate on this "nonliteral constants" point? How is it a problem if DISCONNECTING isn't technically a constant? It follows the Python convention of being in all upper-case, so the programmer understands not to rebind it. Is the problem that someone might (naively or maliciously) change the value of DISCONNECTING, or is the problem that Python doesn't fundamentally know that it won't change? ChrisA