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


Groups > comp.lang.python > #61049

Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <malaclypse2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:not': 0.03; 'attributes': 0.09; 'subject:Why': 0.09; 'variant': 0.09; 'python': 0.11; 'attributes,': 0.16; 'backwards': 0.16; 'minus': 0.16; 'piotr': 0.16; 'subject: \n ': 0.16; 'subject:accessing': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; 'code,': 0.22; '(in': 0.22; 'print': 0.22; 'right.': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; 'too.': 0.31; 'prints': 0.31; 'class': 0.32; 'subject:with': 0.35; 'equal': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'right?': 0.36; 'subject:?': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'new': 0.61; 'today': 0.64; 'subject:there': 0.68; 'subject:being': 0.84; 'proposal,': 0.91; '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:content-transfer-encoding; bh=av+RqZ+4hx6LSztY24NaUk2nHVRQT/SeMYga6gME5sE=; b=csKY5dWWoUFHoeFlnS87Wr76+CwDba7zL7xWzaTSP3G8qg8AgyvY2dFwzzXgHfWDbL yloHheb8ibazQWEOYXLOwNpuYjiFwh5wsqkZEyNnqCfbg8S4dXbx6kW6lvoBo2BYnKAf 46GL95EyhBqueOwYbJLIpVlqZY0ysdSNYbtnwwIlCdl/cOH3F18IOqbpyP2w8y/onfF5 Q6oQW++quPRpjsnQkUCcfVAuWblld8tdJwCtGCvPOa7R3bO1uqN+p1qjgetLW8HbNWCC bP62oVVBbGV131u9AmIOwa1gJytMmei+KsGHvplufXRSEe0StEzowgzn7xCbbCpvofhd rFtQ==
MIME-Version 1.0
X-Received by 10.66.141.165 with SMTP id rp5mr84902806pab.90.1386190701846; Wed, 04 Dec 2013 12:58:21 -0800 (PST)
In-Reply-To <d13e811f-f496-418a-b737-f4fbf1286cc5@googlegroups.com>
References <15912943-29a1-4365-b027-7bb8cec447f8@googlegroups.com> <mailman.3527.1386093834.18130.python-list@python.org> <eb15e1a8-49b1-4d55-a864-141efc65394e@googlegroups.com> <mailman.3543.1386119133.18130.python-list@python.org> <d13e811f-f496-418a-b737-f4fbf1286cc5@googlegroups.com>
Date Wed, 4 Dec 2013 15:58:21 -0500
Subject Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
From Jerry Hill <malaclypse2@gmail.com>
To "python-list (General)" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3586.1386190722.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386190722 news.xs4all.nl 2901 [2001:888:2000:d::a6]:52283
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61049

Show key headers only | View raw


On Wed, Dec 4, 2013 at 3:35 PM, Piotr Dobrogost
<p@google-groups-2013.dobrogost.net> wrote:
> Right. If there's already a way to have attributes with these "non-standard" names (which is a good thing) then for uniformity with dot access to attributes with "standard" names there should be a variant of dot access allowing to access these "non-standard" named attributes, too.

Given the follow code, what do you think should print?

class My_Class(object):
    pass

bar = 1
my_object = My_Class()
setattr(my_object, 'foo', 10)
setattr(my_object, 'bar', 100)
setattr(my_object, 'foo-bar', 1000)

print(my_object.foo-bar)

Today (in python 3.3), it prints 9, because my_object.foo is 10, the
local variable bar is equal to 1, and 10 minus 1 is 9..  Under your
new proposal, it would print 1000, right?  Is there any way for your
proposal to be backwards compatible?

-- 
Jerry

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


Thread

Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-03 09:14 -0800
  Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ned Batchelder <ned@nedbatchelder.com> - 2013-12-03 12:38 -0500
  Re: Why is there no natural syntax for accessing attributes with names
 not being valid identifiers? Dave Angel <davea@davea.name> - 2013-12-03 12:48 -0500
    Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 14:05 -0800
      Re: Why is there no natural syntax for accessing attributes with
 names not being valid identifiers? Dave Angel <davea@davea.name> - 2013-12-04 17:28 -0500
  Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-03 09:31 -0800
    Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-03 15:49 -0800
  Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? random832@fastmail.us - 2013-12-03 13:03 -0500
    Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-03 15:47 -0800
      Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Tim Chase <python.list@tim.thechases.com> - 2013-12-03 19:06 -0600
        Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 12:35 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-04 20:46 +0000
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Jerry Hill <malaclypse2@gmail.com> - 2013-12-04 15:58 -0500
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 13:02 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Neil Cerutti <neilc@norwich.edu> - 2013-12-04 21:41 +0000
            Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 13:54 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Neil Cerutti <neilc@norwich.edu> - 2013-12-06 14:07 +0000
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-06 08:51 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Rotwang <sg552@hotmail.co.uk> - 2013-12-07 00:47 +0000
            Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 14:13 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 15:09 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 15:57 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 16:26 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ned Batchelder <ned@nedbatchelder.com> - 2013-12-04 20:17 -0500
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Terry Reedy <tjreedy@udel.edu> - 2013-12-04 21:58 -0500
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 19:05 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Steven D'Aprano <steve@pearwood.info> - 2013-12-05 07:56 +0000
      Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Tim Roberts <timr@probo.com> - 2013-12-03 21:45 -0800
        Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-03 22:31 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-12-04 01:57 -0700
            Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-04 02:09 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-12-04 11:29 +0100
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-04 04:01 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-12-04 13:32 +0100
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-04 05:02 -0800
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-12-04 20:57 +0100
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Chris Angelico <rosuav@gmail.com> - 2013-12-04 21:33 +1100
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-04 03:27 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Tim Chase <python.list@tim.thechases.com> - 2013-12-04 05:25 -0600
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-04 13:30 +0200
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Chris Angelico <rosuav@gmail.com> - 2013-12-04 22:40 +1100
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 07:56 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-12-04 19:43 -0700
                Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? rusi <rustompmody@gmail.com> - 2013-12-04 20:48 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-04 19:27 -0500
            Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Roy Smith <roy@panix.com> - 2013-12-04 20:03 -0500
        Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 01:12 -0800
        Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Roy Smith <roy@panix.com> - 2013-12-04 08:23 -0500
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 13:00 -0800
        Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 12:07 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 12:22 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-04 20:55 +0000
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Ethan Furman <ethan@stoneleaf.us> - 2013-12-04 13:00 -0800
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Terry Reedy <tjreedy@udel.edu> - 2013-12-04 17:11 -0500
            Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-12-04 15:42 -0800
              Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Terry Reedy <tjreedy@udel.edu> - 2013-12-04 22:21 -0500
          Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers? Rotwang <sg552@hotmail.co.uk> - 2013-12-05 01:50 +0000

csiph-web