[Tutor] Importing classes when needed

Alexandre Conrad alexandre.conrad at gmail.com
Mon May 30 10:38:41 CEST 2011


2011/5/30 Alan Gauld <alan.gauld at btinternet.com>:
> But this means having to maintain the list in init.py.
> Why not use the os functions to read the file names
> dynamically and build the list that way? Provided
> the files use a standard naming scheme you don't
> need to change the init code.

I wouldn't do that. If Timo adds non-parser modules in that directory
(say some utils.py file for all parsers to use), then you have to
maintain a list of excluded files which defeats the purpose of the
problem you are trying to solve: avoid maintaining a list. Plus, you
would already have to exclude __init__.py from the start.

-- 
Alex | twitter.com/alexconrad


More information about the Tutor mailing list