Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76752
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'programmer': 0.03; 'argument': 0.05; 'attribute': 0.07; 'differently': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'windows': 0.15; 'distinct': 0.16; 'exists,': 0.16; 'finney': 0.16; 'imo,': 0.16; 'incorrect': 0.16; 'rather,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'string)': 0.16; 'subject:make': 0.16; 'value.': 0.19; 'examples': 0.20; 'help.': 0.21; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'case.': 0.24; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'initiate': 0.31; 'writes:': 0.31; 'class': 0.32; 'quite': 0.32; 'text': 0.33; 'skip:_ 10': 0.34; 'maybe': 0.34; 'subject:from': 0.34; 'no,': 0.35; 'there': 0.35; 'are,': 0.36; 'two': 0.37; 'clear': 0.37; 'expected': 0.38; 'loss': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'name': 0.63; 'more': 0.64; 'different': 0.65; 'skip:\xe2 10': 0.65; 'between': 0.67; 'products': 0.71; '8bit%:43': 0.74; '8bit%:46': 0.78; '2002': 0.81; 'engineered': 0.84; 'exam': 0.84; 'how.': 0.84; 'received:125': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ben Finney <ben+python@benfinney.id.au> |
| Subject | Re: Distinguishing attribute name from varible name to make codes clear and definite |
| Date | Fri, 22 Aug 2014 06:52:18 +1000 |
| References | <53F5FE8C.7020103@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:qPy5nmD9bBF7W1TMkKBCy5mRDck= |
| 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.13260.1408654353.18130.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408654353 news.xs4all.nl 2883 [2001:888:2000:d::a6]:36767 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76752 |
Show key headers only | View raw
luofeiyu <elearn2014@gmail.com> writes:
> I feel that self.x and x will be confused in the following codes.
I don't see how. The examples you give have the two quite distinct in
every case.
> exam=MyDescriptor("hallo")
>
> when class MyDescriptor initiate , the `hallo` was passed into x in
> __init__(self, x);
That's correct; the argument ‘"hallo"’ (a text string) is the second
argument in the ‘__init__’ call, and the name ‘x’ is bound to that
value while the function executes.
> Literally self.x maybe understood to be self.hallo ,assign a
> attribute named 'hallo' to instance exam.
No, the attribute ‘self.x’ is not to be understood as ‘self.hallo’. The
value is not the name.
If the value of the argument were 7.03, the attribute would not be named
‘self.7.03’, it would still be named ‘self.x’.
> There is a attribute y in instance exam , the `hallo` was passed into
> x in __init__(self, x).No any relation between x and y ,`hallo` and y.
> My view is correct or not ?
You are correct that, if you were to name the attribute differently from
the parameter, there would no longer be any clear relationship.
You are, IMO, incorrect that this would help. Rather, the loss of the
clear relationship would make it much more difficult to see why the
relationship exists, and why different names were chosen.
Instead, the programmer is expected to understand that a value is
distinct from any name which is bound to that value.
--
\ “Our products just aren't engineered for security.” —Brian |
`\ Valentine, senior vice-president of Microsoft Windows |
_o__) development, 2002 |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Distinguishing attribute name from varible name to make codes clear and definite Ben Finney <ben+python@benfinney.id.au> - 2014-08-22 06:52 +1000
csiph-web