summaryrefslogtreecommitdiff
path: root/redis/commands/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'redis/commands/helpers.py')
-rw-r--r--redis/commands/helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/redis/commands/helpers.py b/redis/commands/helpers.py
index b012621..a92c025 100644
--- a/redis/commands/helpers.py
+++ b/redis/commands/helpers.py
@@ -23,3 +23,17 @@ def nativestr(x):
def delist(x):
"""Given a list of binaries, return the stringified version."""
return [nativestr(obj) for obj in x]
+
+
+def parse_to_list(response):
+ """Optimistally parse the response to a list.
+ """
+ res = []
+ for item in response:
+ try:
+ res.append(int(item))
+ except ValueError:
+ res.append(nativestr(item))
+ except TypeError:
+ res.append(None)
+ return res