Req. for module style/organization

RayS rays at blue-cove.com
Sun Feb 19 13:37:09 EST 2006


I've begun a Python module to provide a complete interface to the 
Meade LX200 command set, and have searched for a style/development 
guide for Python Lib/site-packages type modules, but only saw guides 
for C-modules.  I realize that I need to make some changes to follow
http://www.python.org/doc/essays/styleguide.html
better. Does anyone have an appropriate URL for me to follow for this 
task? Is one of the C-module guides appropriate?

I had quickly parsed the official PDF into prototype methods and 
started off, got some good advice from Python-list and MAPUG, and 
broke it into Classes:
http://rjs.org/Python/LX200.zip
Not having written a generic module before, I'd like input on 
organization and style.  As I usually learn from examples, I browsed 
2.4 Lib/site-packages/ and saw a wide variety of structure:
-some have empty __init__.py files, others are loaded
-some have module vars and methods, others not
-some have 0, 1, or many classes per .py file

I have:
LX200/
     __init__.py
     LXSerial.py
     Telescope.py
     Focuser.py
     LXUtils.py
     ... etc
Each file has one class defined.
In the above, LXSerial, Telescope and Focuser are actual separate 
objects (there are others). None can be used without the serial port, 
but some might be used without a scope present. They all ultimately 
rely on a set of atomic serial commands in somewhat overlapping 
categories, not all of which are available on every model device 
(many other makers follow the LX set for its inertia). There is a 
second com port available for optional separate control, but rarely 
used by anyone.
I am trying also to follow the ASCOM standard for names and 
high-level function behavior, as just a subset of the total of 
methods. (ASCOM is the biggest standard in the amateur astro 
industry, but is entirely MS COM, not even CORBA.) That part isn't very hard.

Currently, a user creates a port object, tests ports if desired, then 
opens one (presumably with an LX on the other end, or it Excepts). A 
Telescope object is created before or after, and the port object is 
set as an attribute of the scope. Alternatively, I could require that 
the port is passed explicitly to the Telescope methods, and likewise 
the accessory's methods... There is the issue of inheritance and 
making Classes aware of parents' objects and other Classes' stuff (if needed).

Where in this structure should constants be defined? __init__, 
module*.py, or the module's Class(s)?
Should I rename LXSerial to _serial?
BAUD rate is 9600, so speed here is a non-issue.

The seeming lack of uniformity in the Libs/* is causing my uncertainty:
All advice is appreciated,
Ray




More information about the Python-list mailing list