11 lines
349 B
Python
11 lines
349 B
Python
from typing import List, Any
|
|
|
|
|
|
def filter_integers(values: List[Any]) -> List[int]:
|
|
""" Filter given list of any python values only for integers
|
|
>>> filter_integers(['a', 3.14, 5])
|
|
[5]
|
|
>>> filter_integers([1, 2, 3, 'abc', {}, []])
|
|
[1, 2, 3]
|
|
"""
|
|
return [x for x in values if isinstance(x, int) and not isinstance(x, bool)] |