On 2006-01-12, Ron Griswold <[EMAIL PROTECTED]> wrote:

>> This lacks the beauty of most python code, and clearly feels like 
>> there's somethign I'm missing.  Is there some method or function 
>> I've overlooked that would convert a string to an array with less 
>> song-and-dance?  Thanks,
>
>>      import random
>>      s = "abcdefg"
>>      a = []
>>      a.extend(s)
>>      random.shuffle(a)
>>      s = "".join(a)
>

> Does this do what you are looking for?
>
>>>> s = 'abcdefg';
>>>> a = [];
>>>> a += s;
>>>> a;
> ['a', 'b', 'c', 'd', 'e', 'f', 'g']

That's a bit round-about:

>>> list('abcdefg')
['a', 'b', 'c', 'd', 'e', 'f', 'g']

-- 
Grant Edwards                   grante             Yow!  Yow! Am I cleansed
                                  at               yet?!
                               visi.com            
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to