Again: Please hear my plea: print without softspace

Terry Reedy tjreedy at udel.edu
Fri Mar 5 09:20:52 EST 2004


"Dang Griffith" <noemail at noemail4u.com> wrote in message
news:0370d5ccac8adfc1054d7802ef3e0ba0 at news.teranews.com...
> I'm not trying to be pedantic (at least, I think I'm not trying),

You further clarification makes this more apparent ;-)

>but the difference between a statement and a function is a semantic
> difference, not (just) a syntactic one.

If one views statements as an alternate syntax for expressing functions (in
the general math rather than special Python object sense) on the program
state, then the different is just syntactic.  For instance,

import somemod # is sematically equal to
somemod = __import__('somemod')

and the statement form can be regarded as a shortcut (syntactic sugur) for
the explicit function form, which requires parens, and duplication with
quotes.

Similarly, after 'import __main__',

name = object # abbreviates the more explicit functional form
setattr(__main__, 'name', object)

Note again the need to quote in the functional form.  Most Python
statements do some implicit quoting (as do, for instance, Lisp special
forms and macros).  A hypothetical __def__ function, for instance, would
require quoting of the function and parameter names and the whole code
block, but not the default arg expressions.

> The logic is that "much the same" is not "the same", and is the point
> of the OP's plea.
>
> 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 difference is purely syntax, not sematics in terms of the net effect
on program state, including the contents of the stdout stream.

Perhaps we have different meanings for the word semantics?

Terry J. Reedy







More information about the Python-list mailing list