fn.py
fn.py copied to clipboard
Recursion error with flatten and unicodes
Hey, I get recursion errors on Python 2.7 while executing the following code:
list(flatten([ ['a', u'c'], ['a', 'b'] ]))
I think the issue is here (https://github.com/kachayev/fn.py/blob/master/fn/iters.py#L224), but as I couldn't take a deeper look at it yet, I'm just creating the issue to let you guys know.
Looks like the current implementation would only work in Python 3.
The unicode in u'c'
is causing the issue in your case since unicode
and str
are two different things in Python 2. There is basestring
from which both of these inherit, but using that would only work in Python 2 again.