M
Mike Wyatt
I've been playing around with Python for a few months now, and I just
recently started looking at packages to organize my growing project. So
far, I've been organizing my application into one class per module.
This has been working pretty well. For example, I simply "import
timer", then use "t = timer.Timer()" to allocate a new Timer object, .
Unfortunately, this is yielding some pretty odd syntax when I use
packages. Here is a sample of my package structure:
/engine
/graphics
/input
/world
/timer
timer.py # contains Timer class
main.py
Let's say I want to create a Timer object in main.py. I would need to
do something like this:
import engine.timer.timer.Timer
t = engine.timer.timer.Timer()
Maybe I shouldn't have a module and package with the same name, but it
seems the most logical design. Unfortunately, the code is a bit ugly
with "timer" included in the import three times.
Is there a better way to do this? How do you guys organize your
packages and modules?
recently started looking at packages to organize my growing project. So
far, I've been organizing my application into one class per module.
This has been working pretty well. For example, I simply "import
timer", then use "t = timer.Timer()" to allocate a new Timer object, .
Unfortunately, this is yielding some pretty odd syntax when I use
packages. Here is a sample of my package structure:
/engine
/graphics
/input
/world
/timer
timer.py # contains Timer class
main.py
Let's say I want to create a Timer object in main.py. I would need to
do something like this:
import engine.timer.timer.Timer
t = engine.timer.timer.Timer()
Maybe I shouldn't have a module and package with the same name, but it
seems the most logical design. Unfortunately, the code is a bit ugly
with "timer" included in the import three times.
Is there a better way to do this? How do you guys organize your
packages and modules?