The Python 3 list (dictionary.keys ()) throws an error. What am I doing wrong?

Dictionary:

error['extras'] = {'expiration_month': 'Invalid field [expiration_month] - Missing field "expiration_month"'} 

code:

 list(error['extras'].keys()) 

Result:

 *** Error in argument: "(error['extras'].keys())" 

If necessary, I run this code in a django process, which is suspended by pdb.set_trace ().

+6
source share
1 answer

I believe the problem is that list is a pdb debugger command . The documentation states the following:

Commands that the debugger does not recognize are considered by Python and executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point (!).

So you can try the list prefix like this:

 !list(error['extras'].keys()) 
+21
source

All Articles