[Tutor] Importing classes when needed
Alan Gauld
alan.gauld at btinternet.com
Mon May 30 22:57:27 CEST 2011
"Alexandre Conrad" <alexandre.conrad at gmail.com> wrote
>> 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
I did say he would have to use a naming convention and
that in turn implies the use of glob to filter the names returned.
But I agree it has risks but then, so does relying on
always editing init.py
I just prefer to avoid introducing hard to remember
maintenance tasks when I can do it automatically,
but of course you need to remember the naming convention.
But hopefully a quick 'ls' will do that for you...
Alan G.
More information about the Tutor
mailing list