Suggested coding style

Chris Angelico rosuav at
Thu Sep 29 19:02:29 CEST 2011

On Fri, Sep 30, 2011 at 2:42 AM, Westley Martínez <anikom15 at> wrote:
> But maybe I'm just batty as you all think I am.

Yes, I'm afraid so. Bonkers. Off your head. But let me tell you a
secret... All the best people are.

> Well, I once thought that a print function made a lot of sense.  In C,
> printf is a function, however then I think why print is a function.  In
> C, just about every function has side effects (the return values are
> more often than not either pointers or status codes).  In Python
> functions are encouraged to not have side-effects, so the implementation
> of print as a statement or a method makes far more sense than as a
> function.

Since functions and methods in Python are practically the same thing,
I don't know that there really need be any difference in policy. But I
do like any reduction in the number of "special features" of a
language. If screen output can be done as an ordinary function taking
ordinary arguments, that's better than having a special language
construct. Also, it's just plain stupid and yet just plain cool to be
able to:

print = sys.stderr.write

and smoothly redirect all your prints to stderr. (Unfortunately this
doesn't quite work, as it means you don't get your newlines put in for
you, but there's sure to be an equally stupid/cool reassignment


More information about the Python-list mailing list