Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52678

Re: Importing variables non-deterministic?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'variables': 0.07; 'attributes': 0.09; 'iac': 0.09; 'sure,': 0.09; 'variable,': 0.09; 'variables.': 0.09; 'python': 0.11; 'change;': 0.16; 'constants.': 0.16; 'enum': 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hard- code': 0.16; 'reasonable.': 0.16; 'subject:non': 0.16; 'tradition': 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'meant': 0.20; 'seems': 0.21; '>>>': 0.22; 'example': 0.22; 'import': 0.22; '(in': 0.22; 'aug': 0.22; 'case.': 0.24; 'instance,': 0.24; 'integer': 0.24; 'mon,': 0.24; "i've": 0.25; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'generally': 0.29; 'thus': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'constant': 0.31; 'everywhere': 0.31; 'class': 0.32; 'probably': 0.32; 'could': 0.34; 'problem': 0.35; 'agree': 0.35; 'classes': 0.35; 'but': 0.35; 'received:google.com': 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; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'dave': 0.60; 'more': 0.64; 'dont': 0.67; 'nobody': 0.68; 'fact.': 0.84; "it'd": 0.84; 'pardon': 0.84; 'angel': 0.91; 'avoided.': 0.91; 'hand,': 0.93; '2013': 0.98
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:to :content-type; bh=C8TSa24HaMrs7sZzetxLyVL3r1NVtbTOq672MC0k/oU=; b=gn/SRU7IEd4rMBCSXVYkTICuXZs4IgI28Tso7kU4csAiwnZ5VK+3GCvw2PBmn4B9lc 35KhJEjmDNNmesQHC6B4zEEgC0lShKeAbYlBw3GAJWsqhS0NnZA0iUWI9IOn7dU3leAU foekX3h3YmPeY/ul5qN0bRJQAPp+z8FoOciFOLJqm1BTRzM6k/c6PkncAZtHHgzCiPG/ 1RtNaOAZPkODsHonEeO0EccbQySVgElKujF05qA1CphdjoBYxArXhIjXWLeqgmNtN2AG v7U6VgykAh6vFh0k8jIevE0xLp6lFGesmhuZ4rv20RpvreMVTftkBAxtxVR3YvDgNOxo GpHQ==
MIME-Version 1.0
X-Received by 10.220.110.202 with SMTP id o10mr12072436vcp.1.1376901173391; Mon, 19 Aug 2013 01:32:53 -0700 (PDT)
In-Reply-To <5211D464.5090303@rece.vub.ac.be>
References <a75383ec-b363-4ad4-9703-ca5d8ea614df@googlegroups.com> <520f9054$0$30000$c3e8da3$5496439d@news.astraweb.com> <5211C5BD.5040209@rece.vub.ac.be> <kusidq$kaa$1@ger.gmane.org> <5211D464.5090303@rece.vub.ac.be>
Date Mon, 19 Aug 2013 09:32:53 +0100
Subject Re: Importing variables non-deterministic?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17.1376901181.19984.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376901181 news.xs4all.nl 15940 [2001:888:2000:d::a6]:41592
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52678

Show key headers only | View raw


On Mon, Aug 19, 2013 at 9:16 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> 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.)

In connection.py, I don't care that I've taken a "copy" of the integer
0xFE. It's never going to change; it is a constant in the best
tradition of "named number". I could hard-code 0xFE everywhere and the
code would work *just fine*, but it'd be less readable, so I don't.

Python does have constants. It just doesn't have interpreter support
for them. Same as private members, in fact.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Importing variables non-deterministic? tmellman@googlemail.com - 2013-08-17 07:25 -0700
  Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-17 15:01 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 09:14 +0200
    Re: Importing variables non-deterministic? Dave Angel <davea@davea.name> - 2013-08-19 07:45 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 10:16 +0200
      Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 16:57 +0000
        Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 17:16 +0000
          Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 18:25 +0100
        Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 19:40 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 09:32 +0100
      Re: Importing variables non-deterministic? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-19 17:05 +0000
        Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 22:34 +0200
          Re: Importing variables non-deterministic? Steven D'Aprano <steve@pearwood.info> - 2013-08-20 05:48 +0000
            Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-19 23:40 -0700
            Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-20 08:55 +0200
              Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-20 00:31 -0700
                Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-20 09:55 +0200
                Re: Importing variables non-deterministic? wxjmfauth@gmail.com - 2013-08-20 02:15 -0700
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 11:03 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 10:18 +0100
    Re: Importing variables non-deterministic? Peter Otten <__peter__@web.de> - 2013-08-19 11:49 +0200
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 13:54 +0200
    Re: Importing variables non-deterministic? Dave Angel <davea@davea.name> - 2013-08-19 12:33 +0000
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 16:55 +0200
    Re: Importing variables non-deterministic? Chris Angelico <rosuav@gmail.com> - 2013-08-19 16:04 +0100
    Re: Importing variables non-deterministic? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-19 19:25 +0200
    Re: Importing variables non-deterministic? Ben Finney <ben+python@benfinney.id.au> - 2013-08-20 11:14 +1000

csiph-web