[Tutor] General construction of alpha lists?

Clay Shirky clay at shirky.com
Wed Oct 22 08:31:49 EDT 2003


> On Tue, Oct 21, 2003 at 09:42:46PM -0400, Clay Shirky wrote:
>> So I have this bit of code:
>>       class_groups[next:next+1] = []
> 
> 'del class_groups[next]' will also work.

...and, as I later figured out, 'print class_groups.pop(next)' actually
combines two lines into one.

I thought perl was the one where there was more than one way to do it? ;)
 
> BTW, there is a random.shuffle() function which generates a permutation of a
> list, though it does it by randomly exchanging list elements.

Right, this isn't so much a pressing need as me exploring the language.

> Easiest is probably list(string.ascii_letters),

Perfect, thanks.

The chr(next+65) thing had also occurred to me, but seemed too bletcherous.

-c

> list(string.ascii_lowercase).  string.letters is the list of letters for the
> current locale, and therefore will usually include a bunch of accented
> characters; the .ascii_* variables are fixed.
> 
> --amk
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list