Some "pythonic" suggestions for Python

Terry Reedy tjreedy at udel.edu
Fri Nov 9 20:45:09 CET 2007


"Frank Samuelson" <newsdump0711.12.cudgel at neverbox.com> wrote in message 
news:a9udnTe4ltcoEKnanZ2dnUVZ_hGdnZ2d at cavtel.net...


| My impression was that "consistency" was important to Python.

Important, but not over-riding of all else.

| "Consistency" improves my productivity because I don't have to
| keep referring to the manual.  Things work the way I expect them
| to work.

Different people have different expectations.  I noticed soon after 
learning Python that def, class, and import statements are alternate and 
special forms of name-binding statements.  Some forms of import can be done 
(more awkwardly) as = assignment with the __import__ function.  Indeed, if 
the name of the file to import is not known until runtime (as a string), 
then the import must be so done.  But I never expected function definition 
to done that way.  Perhaps this is because it is special cased in the 
previous languages I have used, from Fortran to C.

To me, complete consistency would demand a syntax like

name = func('name', ('param1', ....), '''
<suite statements>
''')

While anonymous data objects are fine, anonymous code is not.

| Though backward compatibility is not an issue (3.0 breaks stuff),

While there will be minor breakage, backward compatibility was most 
definitely an issue in the design of Python 3 (not pretty well done as far 
as syntax goes).

PS.  If you did not want the hostility you perceive, then I think your 
title was a mistake.  Calling your proposals 'pythonic' invites 
disagreement and distracts from discussion of their merits.

Terry Jan Reedy








More information about the Python-list mailing list