changeset 8:ca8801ad08e9

Fixing inheritence bugs and isprime(1)
author Dominic Cleal <dominic@computerkb.co.uk>
date Mon, 01 Dec 2008 12:51:34 +0000
parents ba09b2802674
children ebaf68ec0784
files primes.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/primes.py	Mon Dec 01 12:44:57 2008 +0000
+++ b/primes.py	Mon Dec 01 12:51:34 2008 +0000
@@ -16,7 +16,7 @@
 			q += 1
 
 class test:
-	cache = { }
+	cache = { 1: False }
 	
 	def __isprime(self, x):
 		for t in range(2, int(math.floor(math.sqrt(x))) + 1):
@@ -24,7 +24,7 @@
 				return False
 		return True
 
-	def __add(self, x, p):
+	def _add(self, x, p):
 		self.cache[x] = p
 	
 	def isprime(self, x):
@@ -36,7 +36,7 @@
 
 class testsieve(test, sieve):
 	def sieve(self):
-		for p in sieve.sieve():
-			test.__add(p, True)
+		for p in sieve.sieve(self):
+			test._add(self, p, True)
 			yield p