Naked function call syntax
Bengt Richter
bokr at accessone.com
Fri Jul 13 22:32:44 EDT 2001
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