parent-child object design question

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Jan 31 18:40:05 EST 2007


"manstey" <manstey at csu.edu.au> writes:

> However, the problem is now that I can also write:
> >>> insOref.Chapter=67
> but we want to disallow this, as insOref.Chapter must remain =
> insProperty

Then don't do that.

Python allows any name to be reassigned to any value, with the
attitude of "we're all consenting adults here". It's better to
document[0] the correct behaviour of
your code, rather than trying to prevent stupid mistakes.


[0]: and unit tests, that explicitly check the behaviour of the code,
and get run all the time during development of the code, are the best
way of documenting behaviour unambiguously.

-- 
 \     "Buy not what you want, but what you need; what you do not need |
  `\           is expensive at a penny."  -- Cato, 234-149 BC, Relique |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list