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

Michael Spencer mahs at telcopartners.com
Mon Apr 18 16:28:21 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. 
> 
See also the source of inspect.getargs for just how much this complicates the 
argument-passing logic!

 > 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?

It appears in a handful of places in the stdlib, mostly tests:
#Search C:\Python23\Lib
# Files *.py
#   For def [\w]+\(\(
c:\python23\lib\test\test_compile.py(49)         def comp_args((a, b)):
c:\python23\lib\test\test_compile.py(53)         def comp_args((a, b)=(3, 4)):
c:\python23\lib\test\test_grammar.py(159) def f5((compound, first), two): pass
c:\python23\lib\test\test_scope.py(318) def makeAddPair((a, b)):
c:\python23\lib\test\test_scope.py(319)     def addPair((c, d)):
c:\python23\lib\site-packages\wx-2.5.3-msw-ansi\wx\lib\imageutils.py(36) def 
makeGray((r,g,b), factor, maskColor):
c:\python23\lib\cgitb.py(82) def html((etype, evalue, etb), context=5):
c:\python23\lib\cgitb.py(168) def text((etype, evalue, etb), context=5):
c:\python23\lib\urlparse.py(118) def urlunparse((scheme, netloc, url, params, 
query, fragment)):
c:\python23\lib\urlparse.py(127) def urlunsplit((scheme, netloc, url, query, 
fragment)):

 >
 > Cheers,
 >
 > AdSR




More information about the Python-list mailing list