structuring a package?

Torsten Mohr tmohr at s.netic.de
Sun Jan 4 19:17:57 EST 2009


Hi,

i have a question on how to structure a package best, would be great if
anybody could give me some hint on this:

Assuming i have a base class GraphicObject and derived from that some
classes like Square, Circle, ...

It looks natural to me to write in a code that uses the package:

import graphic
import graphic.square
import graphic.circle

That way i'd have to structure the code like this:

graphic/
  __init__,py  (GraphicObject)
  square.py (Square)
  circle.py (Circle)

Does that make sense like this?

Are there better ways to structure things in Python?

One thing that bothers me is that when i write in circly.py something like
"import graphic", then i can't have the test code for the Circle within
circle.py, at least it looks to me like this.


The closest thing that handles this issue that i could find was PEP 328, but
it doesn't cover this problem.


Thanks for any hints,
Torsten.




More information about the Python-list mailing list