Re: Converting a string to an array?

2006-01-13 Thread Paul Rubin
Tim Chase [EMAIL PROTECTED] writes: The closest hack I could come up with was import random s = abcdefg a = [] a.extend(s) random.shuffle(a) s = .join(a) You could use import random s = list(abcdefg) random.shuffle(s) s

Re: Converting a string to an array?

2006-01-13 Thread Bryan Olson
Tim Chase wrote: While working on a Jumble-esque program, I was trying to get a string into a character array. Unfortunately, it seems to choke on the following import random s = abcefg random.shuffle(s) returning File /usr/lib/python2.3/random.py, line 250, in shuffle

gracefully handling broken pipes (was Re: Converting a string to an array?)

2006-01-13 Thread Tim Chase
import random s = abcdefg data = list(s) random.shuffle(data) .join(data) 'bfegacd' fit you better? Excellent! Thanks. I kept trying to find something like an array() function. Too many languages, too little depth. The program was just a short script to scramble the

Re: Converting a string to an array?

2006-01-13 Thread Tim Peters
[Bryan Olson] ... For sorting, we had the procedure 'sort', then added the pure function 'sorted'. We had a 'reverse' procedure, and wisely added the 'reversed' function. Hmmm... what we could we possible do about 'shuffle'? 'permuted' is the obvious answer, but that would leave us open to

RE: Converting a string to an array?

2006-01-12 Thread Ron Griswold
Does this do what you are looking for? s = 'abcdefg'; a = []; a += s; a; ['a', 'b', 'c', 'd', 'e', 'f', 'g'] Ron Griswold Character TD R!OT Pictures [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Chase Sent: Thursday, January

Re: Converting a string to an array?

2006-01-12 Thread Grant Edwards
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

Re: Converting a string to an array?

2006-01-12 Thread Xavier Morel
Tim Chase wrote: The closest hack I could come up with was import random s = abcdefg a = [] a.extend(s) random.shuffle(a) s = .join(a) This lacks the beauty of most python code, and clearly feels like there's somethign I'm missing. Is there some