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: 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" Subject: Re: what is the difference between name and _name? Date: Wed, 20 Aug 2014 14:18:18 +0200 References: <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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 "luofeiyu" 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