"Stringizing" a list

Cees de Groot cg at gaia.cdg.acriter.nl
Wed Aug 9 05:42:17 EDT 2000


I'm sure I've seen a place with a snippet for this, but I couldn't find it:

what's the cleanest way to convert a random nested list structure like:

['foo', ['bar', 'baz'], 'quux']

into:

'foo bar baz quux' ?

I've, ahem, solved this with a bit of recursion and relying on '+' to throw
in certain circumstances, but it's a hairy and ugly piece of code. 

-- 
Cees de Groot               http://www.cdegroot.com     <cg at cdegroot.com>
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD  1986 F303 937F E098 9E8B
Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/



More information about the Python-list mailing list