Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56386
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <nedbat@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'convention,': 0.09; 'warn': 0.09; 'cc:addr:python-list': 0.11; 'behavior,': 0.16; 'marco': 0.16; 'name)': 0.16; 'subject:class': 0.16; 'exception': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; '>>>': 0.22; '(in': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'refers': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'names.': 0.31; 'class': 0.32; 'subject:the': 0.34; 'could': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'raising': 0.36; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'does': 0.39; 'name': 0.63; 'to:addr:gmail.com': 0.65; 'to,': 0.72; 'inform': 0.78; '100': 0.79 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=oJQdpyB6VRe35a/FZ43kpZNiEjGnP04v9Y6TP3f3ZBs=; b=jDBLpfeBQxQyLZ+L/5JvZ2ain5bz6tKVHCVcuPS999c3dVhl9zevR30JvpRIwg9YPD n8Tv5jUQuWXd+L3BN2x/M1LNBwsYjg7N1je9lBygSTtLIe3YKDgRORiKASALDfgADlNH 6RSyuCXNrpJIeP5S/8eDGou9494LlHM/sOUcc+WUuABo++QEFqnGaJY49dzCNS2+cd24 RPtm6SU5cbQ1d6zk4TA4kJbIUOg4tfUBfEKQAckUXvtT59CMpY69hE0yaTsGMT+BfHEe HmNhHp1Ju9E9IPU9cDZ8e0vVISxjCQyPIp4W+Hdfjfyq8zeLXnU9qzCa/orV1YR0L1ze RP6g== |
| X-Received | by 10.49.30.98 with SMTP id r2mr1204712qeh.80.1381230475206; Tue, 08 Oct 2013 04:07:55 -0700 (PDT) |
| Sender | Ned Batchelder <nedbat@gmail.com> |
| Date | Tue, 08 Oct 2013 07:07:53 -0400 |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| MIME-Version | 1.0 |
| To | Marco Buttu <marco.buttu@gmail.com> |
| Subject | Re: class-private names and the Zen of Python |
| References | <l30lsq$tfd$1@speranza.aioe.org> |
| In-Reply-To | <l30lsq$tfd$1@speranza.aioe.org> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Cc | python-list@python.org |
| 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.849.1381230484.18130.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1381230484 news.xs4all.nl 15868 [2001:888:2000:d::a6]:54379 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:56386 |
Show key headers only | View raw
On 10/8/13 6:13 AM, Marco Buttu wrote:
> In the following case:
>
> >>> class Foo:
> ... _Foo__a = 100
> ... __a = 33
> ...
> >>> Foo._Foo__a
> 33
>
> I think this behavior, for a user who does not know the convention,
> could be a surprise. Should be raising an exception (in order to
> inform the user the transformation of the name __a have been replaced
> an existing name) a possible --explicit-- alternative?
You also get a "problem" if you do this:
>>> class Foo:
... a = 100
... a = 33
...
>>> Foo.a
33
Or for that matter:
>>> a = 100
>>> a = 33
>>> a
33
There are lots of ways to change what value a name refers to, it's not
an error to reassign names.
Also, as Terry mentions, no one has ever assigned the two names you
show, so why try to warn about it?
--Ned.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
class-private names and the Zen of Python Marco Buttu <marco.buttu@gmail.com> - 2013-10-08 12:13 +0200
Re: class-private names and the Zen of Python Terry Reedy <tjreedy@udel.edu> - 2013-10-08 06:36 -0400
Re: class-private names and the Zen of Python Marco Buttu <marco.buttu@gmail.com> - 2013-10-08 12:47 +0200
Re: class-private names and the Zen of Python Ned Batchelder <ned@nedbatchelder.com> - 2013-10-08 07:07 -0400
Re: class-private names and the Zen of Python Marco Buttu <marco.buttu@gmail.com> - 2013-10-08 13:15 +0200
Re: class-private names and the Zen of Python Ned Batchelder <ned@nedbatchelder.com> - 2013-10-08 12:20 -0400
Re: class-private names and the Zen of Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-08 13:24 +0000
Re: class-private names and the Zen of Python Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-09 00:00 +0100
Re: class-private names and the Zen of Python Marco Buttu <marco.buttu@gmail.com> - 2013-10-09 07:55 +0200
Re: class-private names and the Zen of Python Charles Hixson <charleshixsn@earthlink.net> - 2013-10-09 12:34 -0700
csiph-web