TypeError: 'dict_keys' object does not support indexing
See original GitHub issueHi
I’m trying to do a query on documentdb like this (tested with python 3.4 and 3.6):
query = { 'query': 'SELECT VALUE MAX(c.counter) FROM c' }
#
options = {}
options['enableCrossPartitionQuery'] = True
#options['maxItemCount'] = 2
#
result_iterable = client.QueryDocuments(myCollection, query, options)
results = list(result_iterable);
print(results)
And get:
Traceback (most recent call last):
File "documentdb.py", line 98, in <module>
for i in result_iterable:
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/query_iterable.py", line 107, in __next__
return next(self._ex_context)
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/base_execution_context.py", line 103, in __next__
return self.next()
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/execution_dispatcher.py", line 70, in next
return next(self._execution_context)
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/base_execution_context.py", line 103, in __next__
return self.next()
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/execution_dispatcher.py", line 146, in next
return next(self._endpoint)
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/endpoint_component.py", line 42, in __next__
return self.next()
File "/usr/local/lib/python3.4/dist-packages/pydocumentdb/execution_context/endpoint_component.py", line 98, in next
operator.aggregate(item[item.keys()[0]])
TypeError: 'dict_keys' object does not support indexing
See this link: https://stackoverflow.com/questions/18552001/accessing-dict-keys-element-by-index-in-python3
Could it be that line 98 in endpoint_component.py should have used next(iter(item))
instead of item.keys()[0]
?
Br. Rune
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
TypeError: 'dict_keys' object does not support indexing
keys() returns a dict_keys object which behaves a lot more like a set than a list . As such, it can't be indexed....
Read more >Solved- TypeError: dict_keys object does not support indexing
In this article we learned that view object (dict_keys) returned by dict.keys() doesn't supports the indexing. If someone tries to select element from...
Read more >T101801 "TypeError: 'dict_keys' object does not support ...
In Python 3 the dict.keys() method returns a dictionary view object, which does not support indexing. Details ...
Read more >TypeError: 'dict_keys' object does not support indexing #217
I tired demo.ipynb at google colab. After installing the requirements I started to run the code. There arise an issue in the follwing...
Read more >TypeError: 'dict_keys' object does not support ... - Google Groups
It looks like the issue is that `dict.keys()` returns different types of objects in Python 2 and 3. It returns plain list in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Minimal test case:
Replace with:
Any progress on this?