Sean Ross wrote:
I'll note that it is possible to change
the built-in property (in a backward compatible manner) to be used as a
decorator for this idiom, to redefine parts of properties in sub-classes,
and to provide default get/set/del methods.
Is there a recipe or blog or something somewhere tha
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
> For this reason, I usually suggest declaring properties like[1]:
>
> py> class E(object):
> ... def x():
> ... def get(self):
> ... return float(self._x)
> ... def set(self, x):
> .
Steven Bethard <[EMAIL PROTECTED]> wrote:
> For this reason, I usually suggest declaring properties like[1]:
>
> py> class E(object):
> ... def x():
> ... def get(self):
> ... return float(self._x)
> ... def set(self, x):
> ... self._x = x**2
> ...
Title: RE: built-in 'property'
Thanks to everyone that has helped on this. What I am trying to do is create a capability based api that I can build to order. This is as far as I get at the moment.
Each of the first three classes represents some function I can do to a radio, ther
Steven Bethard wrote:
I seem to be missing some of the messages on this thread, but while
we're talking about properties, it's probably instructive to remind
people that the functions passed to the property function are not
redefinable in subclasses:
py> class D(C):
... def getx(self):
...
Stian Søiland wrote:
On 2004-12-28 12:05:20, [EMAIL PROTECTED] wrote:
class NOTOK(object):
def __init__(self):
self.__x = 0
self.x = property(self.getx, self.setx, self.delx, "I'm the 'x'
property.")
def getx(self): return self.__x - 5
def setx(self, value): self
On 2004-12-28 12:05:20, [EMAIL PROTECTED] wrote:
> class NOTOK(object):
>
> def __init__(self):
> self.__x = 0
> self.x = property(self.getx, self.setx, self.delx, "I'm the 'x'
> property.")
>
> def getx(self): return self.__x - 5
> def setx(self, value):
Title: RE: built-in 'property'
What I want to achieve is a class whereby I can set the property access per instance so the user can test if a property is present using hasattr(klass,'prop') such that the instance has a given capability that can easily be tested by the user
[EMAIL PROTECTED] wrote:
Hi
Can any one explain how property works. It seems to be fine if executed
on import i.e. if the property statement is at class scope.
Properties are meant to be used at the class scope. A property is a kind
of descriptor. See http://users.rcn.com/python/download/Descr