Commits

Jason R. Coombs  committed 16da97e

Use 'next' with default in lieu of 'first'.

  • Participants
  • Parent commits 1ff7325

Comments (0)

Files changed (1)

File pmxbot/logging.py

 		query = dict(nick=nick)
 		cursor = self.db.find(query, fields=fields)
 		cursor = cursor.sort('_id', storage.pymongo.DESCENDING)
-		res = first(cursor)
+		res = next(cursor, None)
 		return res and [res['_id'].generation_time, res['channel']]
 
 	def strike(self, channel, nick, count):
 		return self._generate_search_results(docs)
 
 
-def first(iterable):
-	"""
-	Return the first element from the iterable or None if no element is
-	found.
-	"""
-	try:
-		return next(iterable)
-	except StopIteration:
-		pass
-
 @command("strike", aliases=(), doc="Strike last <n> statements from the "
 	"record")
 def strike(client, event, channel, nick, rest):