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


Groups > comp.lang.python > #76640

what is the difference between name and _name?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <elearn2014@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.076
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'python': 0.11; 'def': 0.12; 'name):': 0.16; 'subject:between': 0.16; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'subject:what': 0.31; 'them?': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'received:google.com': 0.35; 'subject:?': 0.36; 'received:10': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'name': 0.63; 'between': 0.67
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=HuoNnw0ISte4TYeELscmPlGE79PKbSa08bMSvcZB5g0=; b=WpsP0G6TO4GDrOedgqppIDW6sqYkONAyBnsN9uMZ9wJ7I1Av2qBvLQTsFzvkz7p2qg KvfULM3HTLnSTTZVrk1RBsxey/wSWVZQeCyz2n3R4ZHoT1SO5ewf0F79LE+homyiivLb vdqHY/8pTwYHIwgs1LUcU7u1RfFeX8Ze1OsxE2DCqZACoD6VxM9rOGAjDsiyt1FWw3RC 1OU+88rKhbPvwXwstQBkPTnI0KaKJbIQJ84UF0ncI3pvfVbYDr/61EuZYbc2E/7STkGA 8U/gHd4dNPck8pkBk3GYg3pqxZqxEssIUgnm0NCIWZG41BFR7Ufjhh4NM5ed+STSJloQ EPsA==
X-Received by 10.70.6.97 with SMTP id z1mr55594071pdz.120.1408519031581; Wed, 20 Aug 2014 00:17:11 -0700 (PDT)
Date Wed, 20 Aug 2014 15:16:56 +0800
From luofeiyu <elearn2014@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version 1.0
To python-list@python.org
Subject what is the difference between name and _name?
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
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.13190.1408519045.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408519045 news.xs4all.nl 2925 [2001:888:2000:d::a6]:39546
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76640

Show key headers only | View raw


When i learn property in python , i was confused by somename and _somename,what is the difference between them?

class Person(object):
     def __init__(self, name):
         self._name = name
     def getName(self):
         print('fetch....')
         return self._name
     def setName(self, value):
         print('change...')
         self._name = value
     def delName(self):
         print('remove....')
         del self._name
     name = property(getName, setName, delName, "name property docs")


>>> bob._name
'Bob'
>>> pt=Person("peter")
>>> pt.name
fetch....
'peter'
>>> pt._name
'peter'
>>> pt.name="tom"
change...
>>> pt._name="tom"
>>> pt._name
'tom'
>>> pt.name
fetch....
'tom'

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


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