Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Commit

Permalink
int_or_0 is now even more robust
Browse files Browse the repository at this point in the history
int_or_0('a') does not raise a ValueError anymore
  • Loading branch information
Christian Klein committed May 22, 2013
1 parent da2419c commit 99f0cd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions huTools/robusttypecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def int_or_0(data, default=0):
return default

try:
if type(data) in (ListType, TupleType):
if isinstance(data, (ListType, TupleType)):
return int(data[0])
return int(float(data))
except TypeError:
except (TypeError, ValueError):
return default


Expand Down

0 comments on commit 99f0cd0

Please sign in to comment.