Req. for module style/organization

R

RayS

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
 
Z

Ziga Seilnacht

RayS said:
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?

There are two informal Python Enhancements Proposals:
Style Guide for C Code - http://www.python.org/peps/pep-0007.html
Style Guide for Python Code - http://www.python.org/peps/pep-0008.html
I have:
LX200/
__init__.py
LXSerial.py
Telescope.py
Focuser.py
LXUtils.py
... etc
Each file has one class defined.

This style is not encuraged any more because of the ambiguity with
imports; see
http://mail.python.org/pipermail/web-sig/2006-February/002093.html
for details.
All advice is appreciated,
Ray

Ziga
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top