simple-search-engine icon indicating copy to clipboard operation
simple-search-engine copied to clipboard

Indexable class : 'dict_keys' object is not subscriptable

Open jtoghrul opened this issue 6 years ago • 1 comments

When I try to run the project on Python 3, I got : 'dict_keys' object is not subscriptable.

Actually, after some research I have found out that in the following methods list should be added to dictionary keys call.

def __repr__(self):
        return ' '.join(list(self.words_count.keys())[:10])

and

def words_generator(self, stop_words):
        for word in list(self.words_count.keys()):
            if word not in stop_words or len(word) > 5:
                yield word

jtoghrul avatar Mar 01 '18 00:03 jtoghrul

Thanks for the callout, @jtoghrul! The implementation targeted Python > 2.7. It is great to see that it might also work with Python > 3 after a few minor changes.

Would you be interested in adjusting the implementation so that it becomes compatible with both Python 2 and 3? If you submit a pull request I can review and merge it right away.

trein avatar Mar 01 '18 12:03 trein