python development practices?

Peter Wang pzw1
Tue Oct 30 23:49:50 EST 2001


On Tue, 30 Oct 2001 17:56:24 -0800, "John Roth"
<johnroth at ameritech.net> wrote:

>>
>> while i feel that Python makes me far more productive as a programmer
>> for all the projects on which i've worked, i'm inclined to agree that
>> the lack of data hiding coupled with lack of a standard interface
>> specification would cause problems in a team.
>
>IMHO, the data hiding issue is a red hering. If there's someone on the
>team where you absolutely need private variables to keep them honest,
>you've got lots greater problems than the choice of language. In python,
>if you don't want to export a variable or method, simply prefix it with
>an underscore. This will tell anyone who really cares that it's private,
>and if it's used outside, then the code needs to be refactored.

i don't think data hiding's purpose is to keep rogue programmers in
line.  it's partly to insulate imperfect development practice (e.g.
sloppy documentation) and partly to define an interface for a class.
someone else made the point that this is the purpose of documentation,
which should be kept up to date; i agree but people will invariably
look at code, and with python, since the entire code of the class is
exposed (unless you split off a portion of it into a hidden base
class), it's doubly enticing to use stuff you're not supposed to.
also, code can be legacied and documentation will fall short.  in
those cases, the python interpreter is not the code maintainer's
friend.

i've no doubt about the power of python when used with rigorous
development practices.  my question, i guess, is really whether python
is efficient/effective if used without perfect development practices.
if the documentation is a little out of date.  or if a certain
interface isn't fully spec'ed out.  and the guy who wrote the code is
out of town for a week.  are there good practices which safeguard
against these situations?  (beyond perfect development process...)

oh, and the underscore thing seems a bit of a hack in that it
contradicts one of the core principles of python.  decreasing
readibility of the code in order to express class properties to the
interpreter just screams "bolted on".

>Programming requires discipline. Period. If you're depending on a
>compiler
>to catch sloppy thinking, then you've got trouble.

i wouldn't expect a compiler to catch sloppy thinking; but having it
help trap a simple typo in a seldom-encountered bit of code would be
nice, without having to run fully exhaustive code tests.

-peter




More information about the Python-list mailing list