Nomenclature

Martin Pool martinpool at gmail.com
Tue Oct 4 07:34:03 BST 2005


Thanks for raising this; it's good to get it right.

Many of the inconsistencies are my fault, although to be fair mostly
because of ideas about the code changing over time.  Some of the rules
are not well established in Python but we can be consistent in our own
code.

> * revno vs. rev_id

Perhaps we can say "revno" is a single compound word, like filename.

I agree with what John and Aaron said, so let's set these guidelines:

 * revision_id not rev_id

 * Put underscores between lowercase words (so is_file not isfile,
   control_file not controlfile) unless they're a compound word like
   filename.

 * Avoid using "get_" unless it makes the name clearer.  (I can't think
   of a clear rule for this; most functions that return a value are
   in a sense getters.)

 * x_to_y not x2y.

 * Single initial _ on functions that are, in some sense, not for public use.
   Python being what it is this only a hint so they don't have to
   be strictly used inside only one class; it can be enough that
   they're used only in that class or module and its friends.

We should also choose and stick to one convention for docstrings.  I
see there is some epydoc stuff in there.  If people find the output of
it really useful we can standardize on it, but I'd prefer to look at
ReST.

> * inventory.get_idpath() vs. inventory.id2path() (what's the
>   difference?)

As John said they do different things, but the first name is not so good.

We can deprecate some of the methods that don't fit these rules.

--
Martin




More information about the bazaar mailing list