[Python-Dev] Tuple/list assignment question

Nick Coghlan ncoghlan at iinet.net.au
Wed Aug 4 05:21:56 CEST 2004


Dave Cole wrote:

> This begs the question; do you prefer:
> 
>  >>> args = [4, 5, 6]
>  >>> a_func(1, *args)
> 
> or this:
> 
>  >>> args = [4, 5, 6]
>  >>> apply(a_func, [1] + args)
> 
> - Dave

Oh, I certainly prefer the variable argument format, rather than having 
to use apply. The difference is that I've found that useful on several 
occasions, mainly because keyword arguments let you get around the 'only 
at the end' problem.

As far as I know, the new syntax was to able to *completely* replace the 
functionality of 'apply' (I've certainly never needed to use it, no 
matter how complex the variable argument list games got).

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

As soon as the form of your slice changes, you're going to have to 
switch to a generator expression anyway. Hence the question about 
whether or not this special case was special enough to be given its own 
syntax, given that the comparable generator expression really isn't that 
complicated.

*shrug* I'm not implacably opposed or anything - although I'd be 
interested in hearing from those around hear who teach Python as to 
whether they think it would be beneficial or not.

Cheers,
Nick.

-- 
Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268


More information about the Python-Dev mailing list