◐ Shell
clean mode source ↗

Message 122707 - Python tracker

Instead of 
    hasattr(str,'next')

consider using
    isinstance(str, collections.Iterable)

Also consider changing the variable name from the now overly type specific, "str" to something like "source" to indicate the significance of the data, not its type.