[H-GEN] Python query

Peter Robinson pjr at itee.uq.edu.au
Tue Sep 18 19:18:55 EDT 2007


Hi,
Lets say I define a class as follows

class Foo:
    """ Class invariant:  self._x < self._y """

    def __init__(self, x, y):
         self._x = x
         self._y = y

    ......


Now lets say I do the following

f = Foo(10, 2)

That breaks the class invariant so I want to get some sort of failure in 
this case.

What are my options?

I could throw an error inside __init__ - in which case I presume the 
object is not constructed.

Is it possible to have f set to None and if so how do I do that?

Any other ideas?

Peter Robinson







More information about the General mailing list