Permalink
Browse files

improve number decoding

  • Loading branch information...
1 parent 3aec533 commit 746f2bb695689892cf81645edf73ff9d2ef62389 @sunng87 committed Feb 13, 2012
Showing with 5 additions and 7 deletions.
  1. +5 −7 clj.py
View
12 clj.py
@@ -44,12 +44,10 @@
from StringIO import StringIO
def number(v):
- r = None
- try:
- r = int(v)
- except ValueError:
- r = float(v)
- return r
+ if '.' in v:
+ return float(v)
+ else:
+ return int(v)
class CljDecoder(object):
def __init__(self, fd):
@@ -69,7 +67,7 @@ def __get_type_from_char(self, c):
* type name
* a flag to indicate if it's a collection
"""
- if c.isdigit():
+ if c.isdigit() or c =='-':
return ("number", False)
elif c == 't' or c == 'f': ## true/false
return ("boolean", False)

0 comments on commit 746f2bb

Please sign in to comment.