Flattening lists
Tobiah
toby at tobiah.org
Thu Feb 5 14:13:20 EST 2009
More information about the Python-list mailing list
Thu Feb 5 14:13:20 EST 2009
- Previous message (by thread): Flattening lists
- Next message (by thread): os.system issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 05 Feb 2009 11:06:39 -0800, Tobiah wrote:
>
>> Hello everybody,
>>
>> Any better solution than this?
>
> a = [1, 2, 3, [4, 5, 6], [[7, 8], [9, 10]]] print str(a).replace('[',
> '').replace(']', '').split(', ')
>
> ;)
Or:
a = ['text', 'string', 3, [4, 5, 6], [[7, 8], [9, 10]]]
print eval("[" + str(a).replace('[', '').replace(']', '') + "]")
Just tongue in cheek...
- Previous message (by thread): Flattening lists
- Next message (by thread): os.system issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list