On 12/18/2010 2:06 AM, Peter Otten wrote:
I don't think /how/ you are trying it is stupid though I'm not so sure about
/what/ .
Thank you all for very helpful suggestions. It took me a while to chew
on this before I could respond. I learned a lot about descriptors and
their interactions wit
"Steven D'Aprano" wrote
I don't use properties in Python very often (hardly ever in fact)
and I've never used @setter so there may be naming requirements I'm
not aware of. But in general I'd avoid having two methods with the
same name.
That's generally good advice, since one will over-write
Alan Gauld wrote:
"Gregory, Matthew" wrote
class PositiveX(object):
def __init__(self):
@property
def x(self):
@x.setter
def x(self, val):
I don't use properties in Python very often (hardly ever in fact) and
I've never used @setter so there may be naming requirements I'm not
On Sat, Dec 18, 2010 at 11:06 AM, Peter Otten <__pete...@web.de> wrote:
>
> I don't think /how/ you are trying it is stupid though I'm not so sure about
> /what/ .
>
> I didn't get it to work with super() either, so here's Plan B till someone
> is going to enlighten both of us:
>
By no means a sol
Gregory, Matthew wrote:
> Hi all,
>
> Consider the following classes where PositiveX should constrain the
> attribute _x to be positive and SmallX should further constrain the
> attribute _x to be less than 10.
>
> class PositiveX(object):
> def __init__(self):
> self._x = 1
> @p
"Gregory, Matthew" wrote
class PositiveX(object):
def __init__(self):
@property
def x(self):
@x.setter
def x(self, val):
I don't use properties in Python very often (hardly ever in fact)
and I've never used @setter so there may be naming requirements
I'm not aware of. But i
Hi all,
Consider the following classes where PositiveX should constrain the attribute
_x to be positive and SmallX should further constrain the attribute _x to be
less than 10.
class PositiveX(object):
def __init__(self):
self._x = 1
@property
def x(self):
return sel