A Suggestion (please read and respond)
Courageous
jkraska1 at san.rr.com
Mon Oct 30 17:55:41 EST 2000
> > >>>> Attribute error: strict classes only support instance attributes
> > which also exist as class attributes. Valid instance attributes are:
> > 'i' (which is an integer in its class context)
> > Note for classes you can, by overriding the set attr method, implement
> > this now.
>
> Very, very true. Moreover, you can do it by mix-in inheritance
> if you don't need to have your own special meaning for
> __setattr__ (if you do, you will need explicit delegation).
All very good notes. I'd just like to follow up with saying that
I wouldn't mind at all if "strict" were added to Python, perhaps
with functionality outside of classes. I'm not at all sure what
the module and function-level strictness would map to in syntax,
but I'm sure there is something not particularly painful to be
had, somewhere.
For example, at the module level, you could have:
module strict
declare i
declare j
s = 2
>>>> AttributeError: blah blah
... noting the obvious exceptions for attributes which have made
their way into the module by importing and the like. Likewise,
you could have strict functions:
def strict myfunct():
declare i
...
C//
More information about the Python-list
mailing list