programming with Python 3000 in mind

André andre.roberge at gmail.com
Tue Aug 15 17:27:23 EDT 2006


beliavsky at aol.com wrote:
> The current beta version of Python is 2.5 . How can a Python programmer
> minimize the number of changes that will be needed to run his code in
> Python 3000? In general, he should know what is being removed from
> Python 3000 and if possible use the "modern" analogs in Python. A
> manager of Python programmers might want external evidence of
> portability, though (such as an absence of interpreter warnings).

You might want to have a look at PEP-3100 which outlines possible
changes.  You can also follow the discussion on the python-3000 mailing
list. From my reading of this, it looks like there will be relatively
few changes.

> Some basic syntax such as
>
> print "hello world"
>
> is going away to make print look like a function. IMO, fixing what is
> not broken because of the aesthetic tastes of the BDFL is a bad idea.
> His reasoning is at
> http://mail.python.org/pipermail/python-dev/2005-September/056154.html

I don`t see his main reasoning as related to aesthetic taste, but
rather as one of functionality.  As it is, if you use print in your
code (very useful for debugging:-), you're stuck with it.  If print
were a function, you could redefine it at will and very easily, on a
module by module basis, perhaps redirecting the output to a file for
logging or other reasons as described by GvR.

When it comes to *teaching/learning* Python, it makes much more sense
to have print() as a function (same with exec) given what it does
-compared with the purpose of the other keywords.  [I'm not sure I'd do
away with input() though...]

Finally, even though I disagreed above with the characterisation of
this change being related to the "aesthetic tastes of the BDFL", from
what I read it appears that his taste is most often bang-on with the
consensus from experienced programmers; as just a hobbyist myself, I am
constantly amazed at how easy Python code is to read and decipher,
compared with other languages.

André




More information about the Python-list mailing list