Skip to content

Commit c2cdc8a

Browse files
author
Colm Vize
committed
Created isiterable in utils/helpers.py to check if an object is iterable rather than just checking if it's a list. Replaced the check done in read_numbers with this.
1 parent 02baad0 commit c2cdc8a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

bashplotlib/histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def read_numbers(numbers):
3535
"""
3636
Read the input data in the most optimal way
3737
"""
38-
if isinstance(numbers, list):
38+
if isiterable(numbers):
3939
for number in numbers:
4040
yield float(str(number).strip())
4141
else:

bashplotlib/utils/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import sys
99

10+
isiterable = lambda x: hasattr(x, '__iter__') or hasattr(x, '__getitem__')
11+
1012
bcolours = {
1113
"white": '\033[97m',
1214
"aqua": '\033[96m',

0 commit comments

Comments
 (0)