Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29389 > unrolled thread
| Started by | Dave Angel <d@davea.name> |
|---|---|
| First post | 2012-09-17 18:07 -0400 |
| Last post | 2012-09-17 18:07 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to use property? Dave Angel <d@davea.name> - 2012-09-17 18:07 -0400
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-09-17 18:07 -0400 |
| Subject | Re: how to use property? |
| Message-ID | <mailman.841.1347919692.27098.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web