-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
44 lines (33 loc) · 979 Bytes
/
utils.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Utils:
@staticmethod
def is_positive_int(inp):
"""
Returns True if 'inp' parameter is a positive integer
Parameters:
inp: (object): python object
Returns:
is_valid: (bool): Boolean of whether or not 'inp' is valid.
"""
is_positive_int = False
try:
int(inp)
is_positive_int = int(inp) >= 0
except ValueError:
is_positive_int = False
return is_positive_int
@staticmethod
def is_float(inp):
"""
Returns True if 'inp' parameter is a float
Parameters:
inp: (object): python object
Returns:
is_valid: (bool): Boolean of whether or not 'inp' is valid.
"""
is_float = False
try:
float(inp)
is_float = True
except ValueError:
is_float = False
return is_float