1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import argparse
def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
def str2ListOfListsOfLists2int(v):
return [[[[] if c == ' ' else int(c) for c in vii.split(',')] for vii in vi.split(',,')] for vi in v.split(',,,')]
def str2ListOfLists2int(v):
return [[[] if c == ' ' else int(c) for c in vi.split(',')] for vi in v.split(',,')]
def str2list2int(v):
return [int(c) for c in v.split(',')]
def str2list2float(v):
return [float(c) for c in v.split(',')]
def str2list2bool(v):
return [str2bool(c) for c in v.split(',')]
|