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


Groups > comp.lang.python > #42293

Re: Python class and variable issue(newby question!)

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'variables': 0.07; 'attributes': 0.09; 'global,': 0.09; 'subject:question': 0.10; 'python': 0.11; 'def': 0.12; 'attribute.': 0.16; 'attributes.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'in...': 0.16; 'subject:class': 0.16; 'subject:issue': 0.16; 'subject:variable': 0.16; 'variable.': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; '(in': 0.22; 'rules': 0.22; 'java': 0.24; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'agreed.': 0.31; 'bad.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'actively': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'received:209': 0.37; 'mine': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'first': 0.61; 'decided': 0.64; 'different': 0.65; '30,': 0.65; 'mar': 0.68; 'sam': 0.68; 'all!': 0.84; 'berry': 0.84; 'harmful': 0.84; 'subject:!)': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=uaSMtFC6QRTpUzIDktFiiwXPpm7zL0sdin0DSf2QF5E=; b=lHmhur/HgEo2EtLIixKSkmenPRfH1ioLj6xwNpT77bWlt7sR9VOsEpO/K0k3EvZIpN gwZhkteFir/tVOdaHNihdTrnrn5i9OP/9FlB4sp2yvA9kc4dBFpK2XpuSp430u32Sb/J nwWWmrXiCeOhYthR4FoVgwfBAb5+VsDP8bkbiGdd/nwdnkTW5wvnttoo71r7tcly7InR FbPp16AzKM6Cqwkmdu4Li0GJTIW3nIrWu/V8ZDbKSVRftBxbXUIaT+U7QVCMWaCqgUOf Nsi578r9feDgYOOoJFj9FK5sCdw6ZagYFXLSLbScHVrmUni6q27q2+kn29F2EYLbQDhF mtEQ==
MIME-Version 1.0
X-Received by 10.220.231.199 with SMTP id jr7mr3003849vcb.70.1364597962724; Fri, 29 Mar 2013 15:59:22 -0700 (PDT)
In-Reply-To <51561ae3$0$29974$c3e8da3$5496439d@news.astraweb.com>
References <78680654-5cf5-435c-9fce-19d6f5c23360@googlegroups.com> <mailman.3965.1364592243.2939.python-list@python.org> <51561ae3$0$29974$c3e8da3$5496439d@news.astraweb.com>
Date Sat, 30 Mar 2013 09:59:22 +1100
Subject Re: Python class and variable issue(newby question!)
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.3974.1364597970.2939.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364597970 news.xs4all.nl 6938 [2001:888:2000:d::a6]:49704
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42293

Show key headers only | View raw


On Sat, Mar 30, 2013 at 9:51 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Sat, 30 Mar 2013 08:24:00 +1100, Chris Angelico wrote:
>
>> On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry <sambez_14@hotmail.co.uk>
>> wrote:
>>> class test()
>>>     s = 1
>>>
>>>     def test1()
>>>         global s
>>>         s = 2
>
>> That's not a global, that's a class variable.
>
>
> /me thwacks Chris with a halibut.

Ow ow ow, I give in... I am suitably and appropriately thwacked.

> Not only is "class variable" ambiguous, but Python uses different scoping
> rules for "variables" (name bindings) and attributes.

Yes, I should have said class ATTRIBUTE. Sorry all! (Can I blame the
whole 8AM and still up thing? No? Mea culpa, anyhow.)

> I don't know what language first decided to conflate object attributes
> and variables -- I suspect Java -- but it is actively harmful terminology
> (in Python at least, if not in general) and whoever invented it is bad
> and should feel bad.

Agreed. Unfortunately it permeates a lot of programmer's vocabularies,
mine included.

ChrisA

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


Thread

Python class and variable issue(newby question!) Sam Berry <sambez_14@hotmail.co.uk> - 2013-03-29 14:12 -0700
  Re: Python class and variable issue(newby question!) Chris Angelico <rosuav@gmail.com> - 2013-03-30 08:24 +1100
    Re: Python class and variable issue(newby question!) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-29 22:51 +0000
      Re: Python class and variable issue(newby question!) Chris Angelico <rosuav@gmail.com> - 2013-03-30 09:59 +1100
  Re: Python class and variable issue(newby question!) Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-03-29 14:23 -0700
  Re: Python class and variable issue(newby question!) Sam Berry <sambez_14@hotmail.co.uk> - 2013-03-29 15:17 -0700
    Re: Python class and variable issue(newby question!) Chris Angelico <rosuav@gmail.com> - 2013-03-30 09:45 +1100
    Re: Python class and variable issue(newby question!) Dave Angel <davea@davea.name> - 2013-03-29 18:56 -0400

csiph-web