def a((b,c,d),e):

Diez B. Roggisch deetsNOSPAM at web.de
Mon Apr 18 19:08:29 EDT 2005


AdSR wrote:

>> Yes, but usually not so much in function arguments but more in
>> list-comprehensions or other places where unpacking was useful. I
> love the
>> feature - I just don't have nested enough data to use it more :)
> 
> I use tuple unpacking in its typical uses, it's one of the first
> language features I learned about. Somehow it never occurred to me that
> you could use it in function arguments this way - I only knew  f(*args,
> **kwargs) style in this context. That's what I made the whole fuss
> about...

Well, if you think about it the whole positional argument passing is nothing
more than tuple unpacking. Its like having an anonymous variable that gets
unpacked:

def foo(a,b,c = i_m_so_anonymous):
    pass


 So it's just orthogonal to have the full functionality of unpacking
available for function arguments - including the nested tuples.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list