# HG changeset patch # User Jeff Hammel # Date 1305213790 25200 # Node ID 886009132409f5e019dc3452d702bcfb72a85839 # Parent a825f00fe062ed0d6745d505fb05478c45361546 start a dict for type-based stringcasting diff -r a825f00fe062 -r 886009132409 pyloader/cast.py --- 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:]: