python - How can I call an instance function? -
python - How can I call an instance function? -
i have class instance , phone call 1 of instance functions
udp_action = udpactions( application = self.application ) func = getattr( udp_action, 'udp_' + opts['cmd'] + '_fired' )
but i'm getting next error
values instance has no attribute '__getitem__'
where create mistake?
you're using opts
if dictionary (or dictionary-like object), isn't.
it doesn't back upwards ['cmd']
notation, resulting in exception you're seeing.
in [1]: class values(object): pass in [2]: opts = values() in [3]: opts['cmd'] typeerror: 'values' object has no attribute '__getitem__'
python
Comments
Post a Comment