pyfunctools.utils module
- pyfunctools.utils.is_empty(value: any) bool
Checks if the value passed by parameter is empty.
Examples
>>> is_empty('') True >>> is_empty(None) True >>> is_empty([]) True >>> is_empty(Array()) True >>> is_empty({}) True >>> is_empty(()) True
- pyfunctools.utils.is_equal(obj1, obj2) bool
Recursive function that checks if two parameters are equal
Examples
>>> is_equal(1, 1) True >>> is_equal('{}', '{}') True >>> is_equal({}, {}) True >>> is_equal([], []) True >>> is_equal({'language': 'python'}, {'language': 'python'}) True >>> is_equal({'language': 'python'}, {'language': 'js'}) False >>> is_equal(Array(), Array()) True
- pyfunctools.utils.is_float(obj: any) bool
Tests an object and returns true if it is an int value.
- Parameters
obj (any) – Object to test
Examples
>>> is_float(1.0) True >>> is_float(10) False >>> is_float(lambda a: a) False >>> is_float('a') False
- pyfunctools.utils.is_func(obj: any) bool
Tests an object and returns true if it is a function.
- Parameters
obj (any) – Object to test
Examples
>>> is_func(lambda a: a) True >>> is_func('a') False >>> is_func(10) False >>> def func(): ... pass ... >>> is_func(func) True
- pyfunctools.utils.is_int(obj: any) bool
Tests an object and returns true if it is an int value.
- Parameters
obj (any) – Object to test
Examples
>>> is_int(10) True >>> is_int(1.0) False >>> is_int(lambda a: a) False >>> is_int('a') False
- pyfunctools.utils.is_negative(obj: Union[str, int, float]) bool
Check if number is negative
Examples
>>> is_negative('-2') True >>> is_negative('1') False >>> is_negative('1000') False >>> is_negative('-1000') True
- pyfunctools.utils.is_num(obj: any) bool
Check if obj is number
Examples
>>> is_num(10) True >>> is_num(-10) True >>> is_num(+10) True >>> is_num(.10) True >>> is_num('.10') True >>> is_num('a') False
- pyfunctools.utils.is_positive(obj: Union[str, int, float]) bool
Check if number is positive
Examples
>>> is_positive('1') True >>> is_positive('1000') True >>> is_positive('-2') False >>> is_positive('-1000') False
- pyfunctools.utils.to_num(obj: any) Union[int, float]
Generic number converter
- Parameters
obj (any) – Will convert number notation to int or float
- Raises
ValueError – obj is not a number notation, it cannot be converted.
Examples
>>> to_num('10') 10 >>> to_num('1.0') 1.0 >>> to_num('.10') 0.1