• Kirill Smelkov's avatar
    *: dict.keys() returns sequence, not [] on py3 · 7851a964
    Kirill Smelkov authored
    The sequence cannot be randomly accessed, e.g.
    
        In [5]: d = {1:2}
    
        In [6]: kv = d.keys()
    
        In [7]: kv
        Out[7]: dict_keys([1])
    
        In [8]: kv[0]
        ---------------------------------------------------------------------------
        TypeError                                 Traceback (most recent call last)
        <ipython-input-8-643f90e1910b> in <module>()
        ----> 1 kv[0]
    
        TypeError: 'dict_keys' object is not subscriptable
    
    -> Use list(dict.keys()) in places where we need random access.
    7851a964