package question: getting names one level deep?

Steve Purcell stephen_purcell at yahoo.com
Fri Feb 23 13:01:45 EST 2001


Russell E. Owen wrote:
> I like to break my code up into lots of files -- typically one file
> contains a class and turn a related set of files/classes into a package.
> When a file contains a class, naturally I give the file the same name as
> the class.
> 
> However, I've not found a nice way to refer to the resulting classes.
> I hope I'm missing some easy, standard trick.

Ah, well, the easy, standard trick is to group your classes in modules, not
put each class in a submodule of it's 'real' module.

All you're currently doing is breaking one module up into a number of
little files for no concrete reason (c.f. PIL's plugin scheme).

It's a C++/Java idiom that doesn't map too well to Python, without the
application of the voodoo invocations you're soliciting. :-)

Rule #2343: "Be suspicious when something seems complicated in Python."

-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Get servlets at http://pyserv.sourceforge.net/
"Even snakes are afraid of snakes." -- Steven Wright




More information about the Python-list mailing list