Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'attributes': 0.07; 'correct.': 0.07; 'python': 0.09; '@property': 0.09; 'guys!': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'java.': 0.16; 'wrote:': 0.17; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; 'pm,': 0.35; 'subject:?': 0.35; 'but': 0.36; 'bad': 0.37; 'correctly': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'to:charset:iso-8859-1': 0.75; 'received:74.208.4.194': 0.84; 'habit': 0.91 Date: Mon, 17 Sep 2012 18:07:44 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Fernando_Jim=E9nez?= Subject: Re: how to use property? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:+qgPUpqdn+CQJ3KswnalDV+K0+YtX5/QyE7afvowfjD x2/TUMCY0EzyvgCn2VlKMtc81hibEGaq0f6qd02v8y0goue4T4 OoQRgeSqfG2abEIKdB8vIAGsWr613FLVLT+KlOzFUFkmh4JVjc nj0pDCYt3hv6Hek3zKhniGQpMhnymss3137siM/OPG6pvdRDtC wuclT0gT6+rv9bDU9QBVONijMcP+B/u4GQwy8fi6lWZkzw0+cr DS5f7fB7Lng+Jy3QHZ+WV6cQLg3NSpQkzAOa2Kl6v2trkQGxuY uZNpWFyWyvgF6Ckk3LD3L+7VQr4SSS4cm8LNrCchWe0sKkfVg= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347919692 news.xs4all.nl 6872 [2001:888:2000:d::a6]:43205 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29389 On 09/17/2012 05:55 PM, Fernando Jiménez wrote: > Hi guys! > > I'm noob in python and I would know how to correctly use the property. I > have read some things about it but I do not quite understand. > > I found this: > > class C(object): > def __init__(self): > self._x = None > > @property > def x(self): > """I'm the 'x' property.""" > return self._x > > @x.setter > def x(self, value): > self._x = value > > @x.deleter > def x(self): > del self._x > > But I think it's a bad habit to use _ to change the visibility of the > attributes as in JAVA. > > How to correctly use the property? > > That's already correct. But if you don't like _x, then use _rumplestiltskin. -- DaveA