alexbahnisch/pyplus

View on GitHub
docs/common.md

Summary

Maintainability
Test Coverage
A collection of common helper functions to check if an object has characteristics of other objects.

## isintlike(value)

Checks if an object can be converted to an integer.

#### arguments
* **value** *{object}*: The value to check.

#### returns
* *{bool}*: Returns if value can be converted to an integer.

### usages
```python
from pyplus.common import isintlike

isintlike(1)
# => True
isintlike(True)
# => True
isintlike(1.5)
# => True
isintlike("1")
# => True

isintlike("1.5")
# => False
isintlike("one")
# => False
isintlike("inf")
# => False
```

## isintlike(value, include_strings=True)

Checks if an object is iterable.

#### arguments
* `value {object}`: The object to check.
* `include_strings {bool}`: Include strings as an iterable type.

#### returns
* `{bool}`: Returns if value can be iterated.

### usages

```python
from pyplus.common import isiterable

isiterable((0,))
# => True
isiterable([0])
# => True
isiterable({"key": "value"})
# => True
isiterable("string")
# => True

isiterable(1)
# => False
isiterable("string", include_strings=False)
# => False
```