Tim Chase <[EMAIL PROTECTED]> wrote:
>  Just a caveat from past experience...while the OP was talking 
>  about lists, for future reference random.shuffle() chokes on 
>  strings (and possibly tuples).  It requires the ability to edit 
>  the target/parameter in place...a functionality that strings 
>  don't provide.

You can always use array.array('c'), eg

   >>> import random
   >>> import array
   >>> L = array.array('c')
   >>> L.fromstring("hello")
   >>> L
   array('c', 'hello')
   >>> random.shuffle(L)
   >>> L
   array('c', 'elohl')
   >>> L.tostring()
   'elohl'

Which is some way towards a mutable string...

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to