Re: Req. for module style/organization

2006-02-20 Thread RayS
Thanks Ziga,

At 04:42 PM 2/19/2006, you wrote:
RayS wrote:
  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

Thanks, those are helpful and show that I should do some editing throughout.

The
import .moduleName
for relative imports might come into play, as each of the modules of 
the package require the use of LXSerial (oops, I mean: lxserial.Serial :-) )

Given the example structure from Guido:
http://www.python.org/peps/pep-0328.html#guido-s-decision
package/
 __init__.py
 subpackage1/
 __init__.py
 moduleX.py
 moduleY.py
 moduleA.py

seems like it would be appropriate here, but I still need to decide 
on the appropriate hierarchy within the package.
Should it be
lx200/
 __init__.py
 devices/
 __init__.py
 drive.py
 focuser.py
 lxserial.py

which reflects usage hierarchy, or

lx200/
 __init__.py
 drive.py
 focuser.py
 lxserial.py

which is simpler...

I still don't see a consistent rationale where some packages have 
empty __init__.py with all the init stuff in the modules, and others don't.

And then there's the large-ish modules like wxPyPlot that have almost 
everything in one module - I assume that is discouraged.

Thanks for the info,
Ray

-- 
http://mail.python.org/mailman/listinfo/python-list


Req. for module style/organization

2006-02-19 Thread 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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Req. for module style/organization

2006-02-19 Thread Ziga Seilnacht
RayS wrote:
 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

-- 
http://mail.python.org/mailman/listinfo/python-list