multiple assignment

Steven Bethard steven.bethard at gmail.com
Thu Mar 23 11:16:57 EST 2006


Anand wrote:
>>> Wouldn't it be nice to say
>>> id, *tokens = line.split(',')
>>
>> id, tokens_str = line.split(',', 1)
> 
> But then you have to split tokens_str again.
> 
> id, tokens_str = line.split(',', 1)
> tokens = tokens_str.split(',')

Sorry, it wasn't clear that you needed the tokens from the original post.

If you're interested in this, the best route is to write up a PEP and 
provide an implementation.  The new AST in Python makes this kind of 
thing a bit easier.

Steve



More information about the Python-list mailing list