Import without executing module

Ray raykyoto at gmail.com
Mon Feb 2 03:53:54 EST 2009


Hi Stephen and everyone,


On Feb 2, 4:36 pm, Stephen Hansen <apt.shan... at gmail.com> wrote:
> > Maybe he can wrap the things he dont need inside
> > if __name__ == '__main__':
> > check.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> Yeah but he said he doesn't want to modify the file itself-- if he can
> modify the file this can all go away readily, yes.


Thank you for your posts and your explanations; and yes, as you
(Stephen) said here, I'd prefer not to modify it and use it as-is.
Ideally, the original author could have separated the functions from
the top-level code and I would just import the module with the
functions.  But that's whining since the hard work of writing the
functions was already done and I'm very grateful for it; likewise, I'd
like to use of the module unchanged.

As there is no way around it, I'll look into ways of minimizing the
number of changes and the "if" statement mentioned by Kottiyath would
be my next step.  Thank you all for the replies!

Ray





More information about the Python-list mailing list