It looks like you expect your module to behave like a class. You can't access a like that, you need something like
Code:
class Adder(object):
def determineTypes(self, arg1, arg2):
if type(arg1) is not type(arg2):
print 'WARNING...OBJECTS NOT SIMILAR...ERROR MAY GENERATE...'
print 'press enter to continue.'
raw_input('>')
self.adder(arg1,arg2)
else:
self.adder(arg1,arg2)
def adder(self, arg1, arg2):
if type(arg1) is list:
arg1.append(arg2)
self.a = arg1
elif type(arg1) is str:
self.a = arg1 + arg2
elif type(arg1) is dict:
for key in arg2:
self.a = arg1
self.a[key] = arg2[key]
elif type(arg1) in [int, float]:
self.a = arg1 + arg2
else:
#should not happen, just a placeholder
pass
Then
Code:
>>> import adder
>>> add = adder.Adder()
>>> add.determineTypes(.5, .3)
>>> add.a
0.8
>>> add.determineTypes(1,2)
>>> add.a
3
P.S.: You should also consider switching to Python 3, there doesn't seem to be anything stopping you.
Bookmarks