[Tutor] AttributeError: instance has no __call__ method
Marc Gartler
gartler at express.cites.uiuc.edu
Thu Dec 16 03:56:58 CET 2004
Hi everybody,
Prior to this chunk of code 'glass' has been chosen from a list of
colors via user input, and I now want to have that choice connect to
one of several possible classes:
def glass_type(glasstype):
if glasstype == 'Red':
myglass = RedGlassCost()
elif glasstype == 'Blue':
myglass = BlueGlassCost()
elif glasstype == 'Yellow':
myglass = YellowGlassCost()
return myglass
glasschoice = glass_type(glass)
myglass = glasschoice()
I've tried various approaches and keep getting different errors. But
this one seems closest to my goal, as I know it is at least passing
'glass' into the function:
AttributeError: RedGlassCost instance has no __call__ method
What is this trying to tell me? Or is that irrelevant as I would be
better off trying some other approach altogether?
More information about the Tutor
mailing list