[Tutor] Importing classes when needed

Marilyn Davis marilyn at pythontrainer.com
Mon May 30 23:57:24 CEST 2011


If we are coding via a vote, I'd be with Alan.

If Timo adds non-parser modules, and they get through his glob filter,
then surely his code will break with a nice error statement and that would
remind him of his convention.

Or maybe it would just give a verbose report and go on to the next file.

Marilyn

On Mon, May 30, 2011 1:57 pm, Alan Gauld wrote:

> "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.
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list