[Python-Dev] Tuple/list assignment question

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Aug 4 05:50:27 CEST 2004


Nick Coghlan <ncoghlan at iinet.net.au>:

> Whereas the list assignment proposal gives special synactic sugar to 
> *one* form of slicing (x[0], ..., x[n], x[(n+1):]).

It's a comparatively common one, though, I think.  When doing things
like parsing input, it's often natural to want to peel off the first
few items of a list and leave the rest for processing later, based on
what the initial items turn out to be.

Having to explicitly slice off the part you want to unpack not only
seems inefficient (constructing an intermediate list or tuple just to
immediately unpack it and throw it away) it also tends to obfuscate
what is going on.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list