On 29 Apr 2005 11:02:59 -0700, gry@ll.mit.edu wrote:
>I often find myself wanting an instance attribute that can take on only
without checking deeply, are you not sharing state among all instance?
See following for an alternative way, allowing initializatio
Hmm, I had no idea that "property" was a class. It's listed in the
library
reference manual under builtin-functions. That will certainly make
things neater. Thanks!
-- George
--
http://mail.python.org/mailman/listinfo/python-list
The property factory is nice, but have you considered subclassing
property?
class Mode(property):
def __init__(self, *vals):
if [v for v in vals if not isinstance(v,str)]:
raise ValueError, 'Mode values must be strings'
else:
self.values = list(vals)
property.__init__(sel
I often find myself wanting an instance attribute that can take on only
a few fixed symbolic values. (This is less functionality than an enum,
since there are no *numbers* associated with the values). I do want
the thing to fiercely object to assignments or comparisons with
inappropriate values.