

def distinct(self, key):
    'Get a list of distinct values for `key` among all documents\n        in the result set of this query.\n\n        Raises :class:`TypeError` if `key` is not an instance of\n        :class:`basestring` (:class:`str` in python 3).\n\n        With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`\n        or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,\n        if `read_preference` is\n        not :attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or\n        (deprecated) `slave_okay` is `True` the distinct command will be sent\n        to a secondary or slave.\n\n        :Parameters:\n          - `key`: name of key for which we want to get the distinct values\n\n        .. note:: Requires server version **>= 1.1.3+**\n\n        .. seealso:: :meth:`pymongo.collection.Collection.distinct`\n\n        .. versionadded:: 1.2\n        '
    if (not isinstance(key, basestring)):
        raise TypeError(('key must be an instance of %s' % (basestring.__name__,)))
    options = {
        'key': key,
    }
    if self.__spec:
        options['query'] = self.__spec
    options['read_preference'] = self.__read_preference
    options['tag_sets'] = self.__tag_sets
    options['secondary_acceptable_latency_ms'] = self.__secondary_acceptable_latency_ms
    options['slave_okay'] = self.__slave_okay
    use_master = ((not self.__slave_okay) and (not self.__read_preference))
    options['_use_master'] = use_master
    if (self.__max_time_ms is not None):
        options['maxTimeMS'] = self.__max_time_ms
    if self.__comment:
        options['$comment'] = self.__comment
    database = self.__collection.database
    return database.command('distinct', self.__collection.name, uuid_subtype=self.__uuid_subtype, compile_re=self.__compile_re, **options)['values']

dataset/ETHPy150Open blynch/CloudMemeBackend/pymongo/cursor.py Cursor.distinct/original