Again: Please hear my plea: print without softspace

David MacQuigg dmq at gain.com
Fri Mar 5 14:30:35 EST 2004


On Fri, 05 Mar 2004 12:35:01 GMT, Dang Griffith
<noemail at noemail4u.com> wrote:

>In any case, I think the one-liner posted satisfies nearly all of the
>requirements.  
>
>import sys
>def pr(*args): sys.stdout.write(''.join([str(i) for i in args]))
>
>Where it fails is the difference between a function and a statement.
>The OP said [one of] the advantages of a statement is that there is no
>need for parenthesis.  This is the reason I brought up the point that
>a function and a statement are semantically different, and why none of
>the function-based suggestions will satisfy the OP's plea.

The inconvenience of typing a single set of parens seems trivial to me
in comparison to the extra burden of an additional syntax.

In reading someone else's code, I rely on the *syntactic* difference
between functions and statements to convey possibly different
*symantics*.  If it says
print a,b,c
I know exactly what that statement means.  If it says
prn(a,b,c)
I know to look for a definition of 'prn'.  Note that in this case,
there are *two* syntactic differences, the parens and the keyword.
The keyword difference is essential, because you *can* say
print(a,b,c)
and still be using the built-in print statement (although with a
slightly different result.)

So, do what you like with the parens, but leave the keywords alone.
Beyond this one statement, the idea might work as a general
enhancement.  If the first token in a statement is not a keyword, and
the second is not an assignment operator, then look for a function
definition, and don't require parens.  This would allow you to say
'printF a,b,c' or 'importR module'
and have these functions/statements do whatever you want.

At this point my vote for adding more syntax to Python would be -1.  I
prefer the added readability of a more consistent use of parens over
the convenience of leaving them off.  I see the parens as having much
the same role as the unnecessary ':' at the end of some statements.
It clues beginners as to the structure of a statement, and it enhances
readability for experts.

Now if we want to talk about getting rid of 'self.' ... :>)

-- Dave




More information about the Python-list mailing list