I am getting lost here, Python 2.7, I have a dictionary mt
, and I use the get()
method, which by documentation says:
get(key[, default])
Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises aKeyError
.
but I still get
File "/home/ubuntu/subscription-workers/commands/dr/rebilling.py", line 48, in rebill
if mt.get('is_rebill', 0) == 1:
KeyError: 'is_rebill'
Any ideas why?
The mt
is a normal dict
, that sometimes does not have the key.
mt
dict as @TimCastelijns says, but it seems you don't have a key called 'is_rebill' in your dictget()
KeyError
.mt
is not adict
. Useprint type(mt))
and check the output.