(L)
| 1 | def flattenlist(L): |
| 2 | import types |
| 3 | WhiteTypes = ('StringType', 'UnicodeType', 'StringTypes', 'ListType', |
| 4 | 'ObjectType', 'TupleType') |
| 5 | BlackTypes= tuple( [getattr(types, x) for x in dir(types) |
| 6 | if not x.startswith('_') |
| 7 | and x not in whites] ) |
| 8 | |
| 9 | tmp = [] |
| 10 | def core(L): |
| 11 | if not hasattr(L,'__iter__'): |
| 12 | return [L] |
| 13 | else : |
| 14 | for i in L: |
| 15 | if isinstance(i,BlackTypes): |
| 16 | tmp.append(i) |
| 17 | continue |
| 18 | if type(i) == type(str()): |
| 19 | tmp.append(i) |
| 20 | else: |
| 21 | core(i) |
| 22 | return tmp |
| 23 | return core(L) |
| 24 | |
| 25 | |
| 26 |
no test coverage detected