Sorting a list depending of the indexes of another sorted list

J. Peng jpeng at block.duxieweb.com
Mon Jan 21 04:32:42 EST 2008


Steven D'Aprano 写道:
> On Mon, 21 Jan 2008 16:23:50 +0800, J. Peng wrote:
> 
>> J. Peng 写道:
>>
>>>    k = (i.split())[3]
>>>    y = (i.split())[1]
>> btw, why can't I write the above two into one statement?
>>
>> (k,y) = (i.split())[3,1]
> 
> I don't know. What's "i"?
> 
> I'm guessing "i" is a string (and what a horrible choice of a name for a 
> string!) So i.split() will return a list. List indexing with multiple 
> arguments isn't defined, which is why you can't write 
> 
> k, y = (i.split())[3,1]
> 

Thanks.
Then one have to split the list twice.Given the list is large,it's maybe 
not good for performance.Is it a more effective split way?



More information about the Python-list mailing list