How Do I think of import?
Andy at home.com.au
Andy at home.com.au
Sun Apr 5 07:26:27 EDT 2009
Hi:
Sorry for the detail of this question but I hope its useful to others as
well as myself.
I'm planning to do a Python wrapper for an existing GUI environment that
is not one of the standard environments. So I have complete freedom. Ive
done various smaller things in Python with some success. But this is
large enough to need proper planning.
The current environment is C but with a C++ structure. Widgets are
developed from simpler widgets, PtBasic -> PtLabel-> PtButton etc. Each
widget has its own C header that defines widget parameters, callback
options various functions. Each header includes the header defining the
next level down. I plan to extract parameters, bit masks callbacks etc
using a modified h2py, so I have all I need at my fingertips. But how do
I organise it? What structure do I impose on my import files?
The options seem to be:
a) copy the C headers structure!
"from photon.PtButton import *" photon.PtButton imports Its own
definitions and imports photon.PtLabel which imports PtBasic etc.
This is a simple structure. However- all users will import
multiple widgets and I see a lot of wasted effort by Python trying to
import PtBasic and other modules multiple times.
b) Create modules by their function!
photon.defititions, photon.callbacks and photon.functions
then maybe a breakdown under definitions for example.
photon.definitions.PtButton
c) Just give up trying to be efficient and assume that the user will
want to access all definitons etc. Simply create a photon.all and let
that be imported. 'from photon.all import *"
No matter what path I consider, I see a very crowded namespace. Is this
inevitable? Should I just get on with the wrapper and not worry ?
Sizing.. Currently PtBasic has 90 definitions PtLabel 54 and PtButton
11.
Thanks,
Andy
More information about the Python-list
mailing list