mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Return None if there's nothing in the database.
This commit is contained in:
parent
26771923f6
commit
e3c9464634
@ -309,7 +309,10 @@ class DB(object):
|
|||||||
|
|
||||||
def random(self):
|
def random(self):
|
||||||
# XXX This can be optimized not to deserialize each record.
|
# XXX This can be optimized not to deserialize each record.
|
||||||
|
try:
|
||||||
return random.choice(self)
|
return random.choice(self)
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
def size(self):
|
def size(self):
|
||||||
# XXX Likewise as above.
|
# XXX Likewise as above.
|
||||||
|
Loading…
Reference in New Issue
Block a user