Python-list Digest, Vol 42, Issue 117

Bart Willems bwillems at optonline.net
Fri Mar 9 16:35:59 EST 2007


I'm sorry, but what's wrong with:
radix = [ [] ] * 256

Cheers,
Bart

"John"  writes:
>> For my code of radix sort, I need to initialize 256 buckets. My code looks a 
>> little clumsy:
>>
>> radix=[[]]
>> for i in range(255):
>>     radix.append([])
>>
>> any better code to initalize this list? 
>>     
>
> Typically you'd say 
>    radix = [[] for i in xrange(256)]
>
>   





More information about the Python-list mailing list