[Tutor] poll question]

Paul McGuire ptmcg at austin.rr.com
Thu Nov 27 15:58:59 CET 2008


I guess PEP8 gives some tips on how things should be named, and what case to
use, but I think Denis's question goes beyond that.  I think the point of
Denis's question was not to imply that resources like help or docstrings are
not useful, or would not be available.  I think he is polling to see what
the typical Pythonista's intuitive expectation would be for such a routine.
Much of the value of Python (and any Pythonically designed module API) is to
make naming and interface choices that are, well, Pythonic, and that client
code can be productively written without *having* to consult docstrings at
every call.

One point that I think goes along with parameter order is the choice for
defaults.  For example, given his round function example, I think a
reasonable expectation would be that his precision argument would have a
default of 0, so that round(1.23456) would round to the nearest integer.  I
write this even for his hypothetical example, with no help or docstrings.

Joshua Bloch gave a Google talk on the topic of good API design
(http://www.slideshare.net/guestbe92f4/how-to-design-a-good-a-p-i-and-why-it
-matters-g-o-o-g-l-e/), unfortunately, the video no longer seems to be up on
the Google server.  But while one can make general recommendations on "what
is good API design", different languages have their own idioms (idia?) that
might dictate a style or convention consistent with the "feel" of that
language.  In Python, for instance, there is the added feature of named
arguments, which would not be covered in a Java or C++ discussion.

So I think Denis's question was more one of API design, not about guessing.

-- Paul





More information about the Tutor mailing list