Skip to content

Commit bee7bfa

Browse files
committed
Fix flattenList() to ignore strings.
1 parent 37c769b commit bee7bfa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/pvscan.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,14 @@ def expandRange(strng):
10081008
return lst
10091009

10101010
def flattenList(lst):
1011-
"""Flattens a nested list."""
1012-
return [x for sublist in lst for x in sublist]
1011+
"""Flattens a nested list. Does not flatten strings."""
1012+
for x in lst:
1013+
if hasattr(x, '__iter__') and not isinstance(x, basestring):
1014+
for y in flattenList(x):
1015+
yield y
1016+
else:
1017+
yield x
1018+
10131019

10141020
def isNumber(number):
10151021
"""Tests whether number is a number."""

0 commit comments

Comments
 (0)