destroy your self????
dave at pythonapocrypha.com
Thu Oct 20 05:24:17 CEST 2005
> Well I guess what I'm trying to achive is the invalidate the instance
> of the object.
> I have been using None to denote an invalide or uninitialized instance
> of an object.
> There is a degenerate case in my code where a polygon has less than 3
> points and
> I want to class to flag this instance of the object as invalid.
> so.. like super.self = None :)
In Python, variables don't "hold" values - variables are just named references
x = 5 # x refers to the 5 integer object
x = 'hi' # now x refers to the string object
By reassigning a name to something else, that's all you're doing - ever other
reference to that object will still be intact.
If you were able to flag the degenerate case, code that uses the object would
have to check for it, right? That being the case, the same code could just as
easily test a member function.
Better yet, if you can catch this case at the point when the object is created,
just throw an exception or at least perform the test at that point only.
More information about the Python-list