You define your mySetup
variable like this:
mySetup = '''
import Statistics
import random
import hashingLibrary
from CuckooHashing import *
'''
If you just consider that, it’s not a problem at all. However, those lines actually appear within a function declaration:
def recordCuckoo(amtElements, loadFactor):
mySetup = '''
import Statistics
import random
import hashingLibrary
from CuckooHashing import *
'''
So, actually, the content of mySetup
is the following:
'''
import Statistics
import random
import hashingLibrary
from CuckooHashing import *
'''
As you can see, there is an indentation in front of the import
lines, which makes them invalid (because they are executed with no indentation expected). So you should set the setup variable in a different way:
def recordCuckoo(amtElements, loadFactor):
mySetup = '''
import Statistics
import random
import hashingLibrary
from CuckooHashing import *
'''
or maybe something like his:
def recordCuckoo(amtElements, loadFactor):
mySetup = '\n'.join((
'import Statistics',
'import random',
'import hashingLibrary',
'from CuckooHashing import *'
))