'Getting an error trying to convert dict_values to list in ipdb

In Python 3.5 I am trying to get the values from a dictionary like so:

data_dict.values()
# result: dict_values(['117487614', '117487614', '117487614'])

Now if I try to convert this into a list

list(data_dict.values())

I get an error:

*** Error in argument: '(data_dict.values())'

These expressions are being executed inside ipdb:

ipdb> patterns_and_values
{'value_{}.mainContent_root_pwdPin': '85785226', 
'value_{}.mainContent_root_txtBenutzerkennung': '85785226', 
'value_{}.mainContent_root_txtRZBK': '85785226'}

ipdb> patterns_and_values.values()
dict_values(['85785226', '85785226', '85785226'])

ipdb> list(patterns_and_values.values())
*** Error in argument: '(patterns_and_values.values())'


Solution 1:[1]

You're using the ipdb command list from what I can understand. If ipdb follows the interface defined by pdb this doesn't invoke the list() function as you'd expect.

Exit the ipdb debugger to get this to work correctly or, again if ipdb uses the same commands as ipdb, use p list(patterns_and_values.values()) in order to get an expression evaluated inside the debugger.

Solution 2:[2]

Escape your expression with an exclamation mark so ipdb doesn't interpret list as a special command:

!list(data_dict.values())

Solution 3:[3]

you can try this:

patterns_and_values = {'value_{}.mainContent_root_pwdPin': '85785226', 'value_{}.mainContent_root_txtBenutzerkennung': '85785226', 'value_{}.mainContent_root_txtRZBK': '85785226'}
only_values = patterns_and_values.values()
value_list = [x for x in only_values]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dimitris Fasarakis Hilliard
Solution 2 joshlk
Solution 3 Ashish