Get ratio of code and pattern matched

def getratio(self, code) :
		""" Get ratio of code and pattern matched
		"""
		if len(code) == 0 : return 0

		code_replaced = self.prog.sub('', code)
		return (len(code) - len(code_replaced)) / len(code)