how to use more than 1 __init__ constructor in a class ?

wittempj@hotmail.com martin.witte at gmail.com
Wed Jun 22 14:44:09 EDT 2005


You also could use a list to represent your data, then you get more
dimensions supported, e.g:
import math
class Point:
	def __init__(self, *args):
		self.points = list(args)

def dist(x, y):
	if len(x.points) != len(y.points):
		raise RuntimeError('dimensions not the same')
	d = 0
	for i in range(len(x.points)):
		d += (x.points[i] - y.points[i])**2
	return math.sqrt(d)




More information about the Python-list mailing list