Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76661
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'interpreter': 0.05; 'attribute': 0.07; 'permitted': 0.07; 'explanation': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'wrote': 0.14; 'in-depth': 0.16; 'name):': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:between': 0.16; 'trying': 0.19; 'examples': 0.20; '>>>': 0.22; 'first,': 0.26; 'header:X-Complaints-To:1': 0.27; 'doc': 0.31; 'lot.': 0.31; 'subject:what': 0.31; 'class': 0.32; 'url:python': 0.33; 'skip:_ 10': 0.34; 'received:co.za': 0.34; 'received:za': 0.34; 'subject:the': 0.34; 'problem': 0.35; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'google': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'url:org': 0.36; '(3)': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'use.': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'name': 0.63; 'here': 0.66; 'frank': 0.68; 'prompt': 0.68; 'received:41': 0.70; 'confusing': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | "Frank Millman" <frank@chagford.com> |
| Subject | Re: what is the difference between name and _name? |
| Date | Wed, 20 Aug 2014 14:18:18 +0200 |
| References | <mailman.13190.1408519045.18130.python-list@python.org> <53f46100$0$29884$c3e8da3$5496439d@news.astraweb.com> <53F48957.8020700@gmail.com> |
| X-Gmane-NNTP-Posting-Host | 41-135-111-185.dsl.mweb.co.za |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.3790.4657 |
| X-RFC2646 | Format=Flowed; Response |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.3790.4913 |
| 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.13204.1408537124.18130.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408537124 news.xs4all.nl 2971 [2001:888:2000:d::a6]:60986 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76661 |
Show key headers only | View raw
"luofeiyu" <elearn2014@gmail.com> wrote in message
news:53F48957.8020700@gmail.com...
> So in this example:
>>> class Person(object):
>>> def __init__(self, name):
>>> self._name = name
>> [...]
>>> name = property(getName, setName, delName, "name property docs")
>>
>>
>> (3) name is the public attribute that other classes or functions are
>> permitted to use.
>>
>>
>> problem 1: there is no self.name = something in the defination ,why i
>> can get bob.name?
>>
>>
I also found it confusing at first, but reading the docs and trying out the
examples at the interpreter prompt helped a lot.
Here is the relevant doc page -
https://docs.python.org/3/library/functions.html#property
If you really want to know what goes on under the hood, Google turned up
this in-depth explanation -
http://stackoverflow.com/questions/17330160/how-does-the-property-decorator-work
HTH
Frank Millman
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
what is the difference between name and _name? luofeiyu <elearn2014@gmail.com> - 2014-08-20 15:16 +0800
Re: what is the difference between name and _name? Steven D'Aprano <steve@pearwood.info> - 2014-08-20 08:49 +0000
Re: what is the difference between name and _name? luofeiyu <elearn2014@gmail.com> - 2014-08-20 19:41 +0800
Re: what is the difference between name and _name? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-21 01:26 +1000
Re: what is the difference between name and _name? luofeiyu <elearn2014@gmail.com> - 2014-08-21 10:20 +0800
Re: what is the difference between name and _name? Chris Angelico <rosuav@gmail.com> - 2014-08-21 13:10 +1000
Re: what is the difference between name and _name? luofeiyu <elearn2014@gmail.com> - 2014-08-22 14:37 +0800
Re: what is the difference between name and _name? "Frank Millman" <frank@chagford.com> - 2014-08-20 14:18 +0200
csiph-web