def a((b,c,d),e):
Diez B. Roggisch
deetsNOSPAM at web.de
Mon Apr 18 18:01:50 EDT 2005
AdSR wrote:
> Fellow Pythonistas,
>
> Please check out
>
> http://spyced.blogspot.com/2005/04/how-well-do-you-know-python-part-3.html
>
> if you haven't done so yet. It appears that you can specify a function
> explicitly to take n-tuples as arguments. It actually works, checked
> this myself. If you read the reference manual at
> http://docs.python.org/ref/function.html
> really carefully, you will find that it is indeed part of the language
> spec, but it's a likely candidate for the least advertised Python
> feature. Small wonder since it looks like one of those language
> features that make committing atrocities an order of magnitude easier.
>
> Has anyone actually used it in real code?
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 :)
What python offers in this respect can be seen as a limited form of
pattern-matching known from functional programming - and instead of beeing
considered an atrocity it's actually frequently requested to be enhanced.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list