Is this a valid use of 'import'?

Tim Golden mail at timgolden.me.uk
Tue Jul 22 11:22:54 EDT 2008


Frank Millman wrote:
> In this particular case, when it is executed, it does a whole lot
> more. It reads in some parameters, establishes a socket connection,
> starts a thread, and starts monitoring the socket using select.select.
> It also exposes some functions that disguise the complexity of reading
> from and writing to the socket.

This is not, in general, a good idea, no matter how appealing!
There is some subtle stuff going on within the chain of imports,
and firing off a new thread is quite likely to confuse it in
nasty ways later on. Less attractive though it may be, you're
better off having a "startup" function or whatever and calling
that:

import Utils.client
Utils.client.startup ()

TJG



More information about the Python-list mailing list