Raymond Hettinger a écrit :
> [Brian Harring]
> 
>>The issue I'm seeing is that the wart you're pointing at is a
>> general issue not limited to strings- everyone sooner or later
>> has flattening code that hits the "recursively iterate over
>> this container, except  for instances of these classes".  
> 
> 
> Good recap.  For more info, search comp.lang.python for previous
> discussions about a proposed iter_flatten() function.  One of the
> conclusions was that a general algorithm would need to accept a user
> specified test for atomicity so it would know where to recurse and a
> where not to (the answer to that is application dependent).
> 
one useful test for that case could be:
 >>> item in item

This returns True for string-like objects, False for other sane (non infinite) 
iterables. Anyhow, when it returns True, you most definitely want to stop 
recursing!

Baptiste

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to