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



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

.



Relevant Pages

  • RE: Query to populate list
    ... test and the query works well. ... Questions/answers ... Def is a number of person. ... I think we could make it a smaller Sub if I had more ...
    (microsoft.public.access.modulesdaovba)
  • Re: Spotlight Searching in Python - Mac OSX
    ... # create and initalize our query ... def hideApplication_: ... # the NSMetadataQuery will send back a note when updates are ... return predicate ...
    (comp.lang.python)
  • [PHP-CHECKER] 99 potential SQL injection vulnerabilities
    ... vulnerabilities by inspecting strings echo'ed back as HTML output. ... $tempid is not validated before being passed into the query ... Def: line 35; Use: line 44 ... 20 potentially exploitable SQL injection vulnerabilities ...
    (Bugtraq)
  • Re: Application Design
    ... object (which I shall call a 'Query') that can be *reused*, ... def Article::attributes ... def call(array) ... Articles are in an Array; ...
    (comp.lang.ruby)
  • Re: Can I use decorators to manipulate return type or create methods?
    ... the query in several different ways: ... wondering if I can use decorators to accomplish this. ... def getUsersAsXML(self, params): ...
    (comp.lang.python)

Loading