Mercurial > hg > pyloader
changeset 6:886009132409
start a dict for type-based stringcasting
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 12 May 2011 08:23:10 -0700 |
parents | a825f00fe062 |
children | 79676a48f6d8 |
files | pyloader/cast.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pyloader/cast.py Thu May 19 12:26:29 2011 -0700 +++ b/pyloader/cast.py Thu May 12 08:23:10 2011 -0700 @@ -47,6 +47,11 @@ casts = [int, float, str2bool, str2list, str2args] cast = StringCaster(*casts) +# cast by type +cast_dict = dict([(i,i) for i in int, float]) +cast_dict[bool] = str2bool +cast_dict[tuple] = cast_dict[list] = str2list + if __name__ == '__main__': import sys for arg in sys.argv[1:]: