alternate function call syntax

Alex Martelli aleaxit at yahoo.com
Wed Oct 6 05:32:26 EDT 2004


Helmut Jarausch <jarausch at igpm.rwth-aachen.de> wrote:

> Alex Martelli wrote:
> .....
> > It's not really a "sort of thing", alas... print is a statement so it
> > lives by its own rules (a Python wart, Guido's admitted that; maybe it
> > will change in Python 3000... let's hope!).
> 
> Is there any chance that Python 3000 would allow an alternate function call
> in addition to the standard function call

I suspect the chance is smaller than the proverbial snowball's in hell,
but surely there must be some, infinitesimal though it might be (e.g.,
aliens _could_ abduct the real Guido and replace him with a craftily
programmed droid).  Apart from the issue of being able to freely mix
keywords like 'from' and plain identifiers like 'to' in exactly the same
role (a big mess in itself -- let's just assume it away), calling:

integrate(sin, from=0.0, to=3.14)

is already possible today, and the ability to remove the punctuation to
give your desired:

> integrate sin from 0.0 to 3.14

is a kind of "let's add yet another syntax sugar possibility to the mix"
direction which it definitely _doesn't_ look like the trend for Python
3000 (simplification, removal of legacy issues, stronger emphasis on
"there should ideally be only one way", look more like that trend).

> Then 'print' could just be a standard function.

If you mean "with today's syntax", no it couldn't.  The print statement
has this weird, unique syntax whereby it can have a trailing comma in a
meaningful sense, meaning "emit no endline here".  Not to mention the
ever-lovin' "print>>BAH,buh"... Were it not for those warty quirks, any
current use of, e.g.:
    print a, b, c
could already be identically translated to
    printfunc(a, b, c)
with (net of softspace issues but just for brevity):
def printfunc(*args):
    sys.stdout.write(' '.join(map(str,args))+'\n')

The parentheses aren't the big deal, and your proposed syntax for
alternate function calls (with those 'keywords' corresponding to nothing
like print uses today) doesn't seem as if it would help much here,
anyway...


Alex



More information about the Python-list mailing list