Popular style document?

Greg Weeks weeks at vitus.scs.agilent.com
Wed Mar 20 08:52:35 EST 2002


Is there a popular style document for Python?  I realize that there isn't a
whole lot of scope for such a thing, but I wondered because of certain
particular issues that came to mind.


1.  I use "me" instead of "self" in method definitions.  I mention this not
to ask what people think -- I have an unpleasant suspicion -- but because
I'll be using "me" below.


2.  How should methods call other methods?  Suppose that show_and_tell()
simply calls show() and then tell().  Let the class be, say, "Demo".  Then
there are two choices:

    def show_and_tell(me):
	me.show()
	me.tell()

    def show_and_tell(me):
	Demo.show(me)
	Demo.tell(me)

These have different semantics for subclasses, but I would hate to choose
based on that.  I simply use the first alternative.  But only the second
alternative was given in "Python Essential Reference" (by David Beazley).
So I wonder.


3.  Personally, I think that code is more readable (at least sometimes)
when global variables are "declared".  But how?  If within a comment, what
form does the comment take?  Unable to answer that question, I found myself
using a "global" statement, which is semantically a no-op and only
acceptable if the reader knows what the heck it is doing there.


These are hardly burning issues.  But if these or similar issues happen to
be addressed somewhere, I'd like to take a look.


Greg




More information about the Python-list mailing list