Reputation: 2014
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())'
Upvotes: 7
Views: 3345
Reputation: 1651
Escape your expression with an exclamation mark so ipdb doesn't interpret list
as a special command:
!list(data_dict.values())
Upvotes: 3
Reputation: 2489
d = {"d":1,"s":1}
print (d.values())
print(list(d.values()))
Keep Coding Keep learning
Upvotes: -3
Reputation: 160377
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.
Upvotes: 21
Reputation: 4330
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]
Upvotes: 0