Skip to content

Commit

Permalink
Implement next() for python2.4 and 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lmacken committed Jun 20, 2013
1 parent c5a320c commit ff62afd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions quantumrandom/__init__.py
Expand Up @@ -72,6 +72,16 @@ def _object_hook(obj):
if obj.get('type') == 'string':
obj['data'] = [s.encode('ascii') for s in obj['data']]
return obj

if sys.version_info[1] in (4, 5):
_sentinel = object()
def next(it, default=_sentinel):
try:
return it.next()
except StopIteration:
if default is _sentinel:
raise
return default
else:
def get_json(url):
return json.loads(urlopen(url).read().decode('ascii'))
Expand Down

0 comments on commit ff62afd

Please sign in to comment.