mirror of
https://github.com/kennethreitz/records.git
synced 2026-06-05 06:46:17 +00:00
Switch to index access for idiomaticity
This commit is contained in:
+4
-4
@@ -205,16 +205,16 @@ class RecordCollection(object):
|
||||
|
||||
# Try to get a record, or return default.
|
||||
try:
|
||||
record = next(self)
|
||||
except StopIteration:
|
||||
record = self[0]
|
||||
except IndexError:
|
||||
if isexception(default):
|
||||
raise default
|
||||
return default
|
||||
|
||||
# Ensure that we don't have more than one row.
|
||||
try:
|
||||
next(self)
|
||||
except StopIteration:
|
||||
self[1]
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
raise ValueError('RecordCollection contains too many rows.')
|
||||
|
||||
Reference in New Issue
Block a user