Naked function call syntax

simonb at webone.com.au simonb at webone.com.au
Fri Jul 13 23:20:49 EDT 2001


right.
I do this for lists:

 >>>def lprint(alist):
 >>>     for a in alist:
 >>>        print str(a)

so that i don't get repr of elements.
And it would be great to be able to write:
 >>> lprint alist
just like print...

Im not sure i understand the proposed resolution of
leading '[' or '('...
"print(1,2)" prints a tuple, so wouldn't
you have to mark functions as "naked"
so that a tuple would be sent as the first argument?

 >>>def naked lprint(alist):
 >>>...

Well, this sounds rediculous to me.
what about:

 >>>def lprint alist:
 >>>...

?
Simon.


Bengt Richter wrote:

>Interactively, I find myself writing little things like:
>
>def pd(x):
>    try:
>        print x.__doc__
>    except:
>        print '(no doc string)'
>
>so that, e.g., I can type
>
>    pd(vars)
>
>and get formatted info. But I'm lazy enough that
>I would like to to type just
>    pd vars
>
>Is there an existing pythonic way to do this?
>
>If not, would there be breakage if python were modified to make
>
>    foo whatever-up-to-EOL
>
>equivalent to
>
>    foo(whatever-up-to-EOL)
>
>when it would be a syntax error otherwise? I.e., I'm wondering
>if the grammar could be modified to do this by changing trailer
>to accept arglist NEWLINE if _all_ else fails, and treat a match
>as if it was an arglist. Leading '(' or '[' ambiguity would be
>resolved in favor of normal arglist or subscriptlist.
>
>




More information about the Python-list mailing list