[SciPy-dev] P3 - my education [was: change print statements to print functions in docstrings]

Nathaniel Smith njs@pobox....
Sat Aug 15 14:18:35 CDT 2009

(Replying in public in the vain -- in both senses -- hope that this
might finish the discussion.)

> Um, why?  Perhaps it stems from one's personal preference regarding the way
> one prefers to program?  Having "grown-up" a procedural programmer, I'm now
> an OO "true believer," though I feel that one of Python's greatest strengths is
> that it fully supports "going both ways"; because of that, I feel neither function
> nor method has the edge in being more Pythonic.

In 2.x, print is neither a function nor a method. It's a statement
with its own syntax, comparable to "for" or "try" or "if". (And it's
actually relatively bizarre syntax -- there's a special construct
involving ">>" for directing print output to a file that's totally
unlike anything else in Python, etc.) This is confusing, especially
for newcomers, because the first 'function-like' operation they learn
follows its own rules that don't generalize to anything else.

Also, this makes it possible to have variables, methods, functions in
a local scope that are named "print", which might be handy sometimes:
  class Printer:
    def print(self, document): # <-- in 2.x this is a syntax error

In any case, it is the way it is, at this point -- 3.0 was released
last year :-).

-- Nathaniel

More information about the Scipy-dev mailing list