large class hierarchies in python

Justin Dubs jtdubs at eos.ncsu.edu
Sat Sep 8 21:38:04 EDT 2001


Hey guys,

I'm new to python, as of last week.  I know several other OO langauges
though.  Anyway, I am having trouble getting a hierarchy of "modules" to
behave as I would like them to.  I guess I have several questions, or maybe
just one long one.

I love python's syntax and functionality.  I'm not sure, however, if I am
the least bit pleased with the way it deals with "modules".  I probably just
don't understand what I'm doing.  I'm trying to pretty much do Java style
package hierarchies with python modules and I'm not sure if it is
possible/appropriate.

I want the directory structure to be the module (package?) structure of the
program.  And I want each class to exist in a file of the same name.  I
haven't yet gotten this concept to mesh well with the python module/import
paradigm.  For example:

/
/agent
/agent/Agent.py
/agent/Environment.py
/agent/grid
/agent/grid/GridAgent.py
/agent/grid/GridEnvironment.py

Here, GridAgent and GridEnvironment inherit from Agent and Environment,
respectively.  I assume each directory will need a __init__.py file, but I
really don't understand what to put in it to have it behave the way I'd
like.  Any suggestions?

Also, as a maybe simpler question:

Is this entire method of programming just not going to work out with Python?
Is Python not suitable for this type of problem?  If not, what languages do
you know of that are syntactially similar to Python and WOULD be
appropriate?

Thanks a lot guys,

Justin Dubs





More information about the Python-list mailing list