[Tutor] Using type

ALAN GAULD alan.gauld at btinternet.com
Fri Aug 12 11:31:54 CEST 2011


> It'll work on lists and tuples, for simple examples.  But beware that 
> when you iterate through strings, the individual characters are also 
> strings, and this function will fail with an error like:
>    RuntimeError: maximum recursion depth exceeded

Oh, good catch Dave.

So you'd want to add an explicit check for a string.
And in  fact you probably don't want to "flatten" a string into 
individual characters anyway!

Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110812/b1e7eb96/attachment-0001.html>


More information about the Tutor mailing list