[Tutor] Deleting from within a class

Richard Wilkins rwilkins@bigpond.net.au
Tue, 27 Mar 2001 20:13:27 +0800


Hi everyone,

I'm creating a matrix class for fun (?!). In the initialisation of the class
I want it to check whether the matrix dimensions are all correct (this is
sort of irrelevant, but I just wanted to set the scene). What I want to
know, is how can I delete an instance within one of its methods - __init__()
or something else if possible. I tried "del self", but the instance
remains...

class Matrix(self,array):
	def __init__(self,array=[[1,0],[0,1]]):
		for row in array:
			if len(row)!=len(array[0]):
				del self
				return
		self.dimensions=[0,0]
		self.elements=None
		self.update_elements(array)
	.
	.
	.

Any and all help will be appreciated =)

TIA, Andrew Wilkins