Steve Holden holdenweb.com> writes:
> You want assignment to a method-local variable to turn an attribute into
> a property? That's programming with a magic wand ...
>
> That will depend on the value returned by property access, surely?
>
> I suspect you are a little confused about propertie
David S. wrote:
Steve, and others, thanks for the help. This and Michael Spencer's reply
at http://article.gmane.org/gmane.comp.python.general/390478 have been very
helpful in getting the descriptor definition clear. For me, it has taken
reading http://users.rcn.com/python/download/Descriptor.ht
David S. wrote:
Steven Bethard gmail.com> writes:
David S. wrote:
I am looking for a way to implement the same simple validation on many
instance attributes and I thought descriptors
(http://users.rcn.com/python/download/Descriptor.htm) looked like the
right tool.
Looks like you're trying to
Steven Bethard gmail.com> writes:
>
> P.S. If you haven't already, you should read
> http://users.rcn.com/python/download/Descriptor.htm a couple of times.
> It took me until about the third time I read it to really understand
> what descriptors were doing. The big thing to remember is that
David S. wrote:
Steven Bethard gmail.com> writes:
Looks like you're trying to reinvent the property descriptor. Try using
the builtin property instead:
py> def getchar(self):
... if not hasattr(self, '_char'):
... self._char = None
... return self._char
...
py> def setchar(self,
David S. wrote:
This still fails to work for instances variables of the class. That is
if I use your property in the following:
py> ...class Flags(object):
...def __init__(self):
... a = singlechar
...
you should write that as:
class Flags(object):
a = singlechar
def
Steven Bethard gmail.com> writes:
>
> David S. wrote:
> > I am looking for a way to implement the same simple validation on many
> > instance attributes and I thought descriptors
> > (http://users.rcn.com/python/download/Descriptor.htm) looked like the
> > right tool.
> >
> Looks like you'r
David S. wrote:
I am looking for a way to implement the same simple validation on many
instance attributes and I thought descriptors
(http://users.rcn.com/python/download/Descriptor.htm) looked like the
right tool.
But I am confused by their behavior on instance of my class.
I can only get th
I am looking for a way to implement the same simple validation on many
instance attributes and I thought descriptors
(http://users.rcn.com/python/download/Descriptor.htm) looked like the
right tool.
But I am confused by their behavior on instance of my class.
I can only get the approximate be