Insert to MongoDB collection that has unique key with Python
<p>I have a collection called englishWords, and the unique index is the "word" field.
When I do this</p>

<pre><code>from pymongo import MongoClient

tasovshik = MongoClient()
db = tasovshik.tongler
coll = db.englishWords

f = open('book.txt')
for word in f.read().split():
    coll.insert( { "word": word } } )
</code></pre>

<p>I get this error message <pre>pymongo.errors.DuplicateKeyError: E11000 duplicate key error index: tongler.englishWords.$word_1 dup key: { : "Harry" }</pre>, but it stops to insert when the first existing word is to be inserted.</p>

<p>I do not want to implement the check of existence, I want to use the benefits of unique index with no problems. </p>