On Fri, Mar 5, 2010 at 12:25 PM, Pete Emerson <pemer...@gmail.com> wrote: > On Fri, Mar 5, 2010 at 12:17 PM, Chris Rebert <c...@rebertia.com> wrote: >> On 3/5/10, Pete Emerson <pemer...@gmail.com> wrote: >>> In a module, how do I create a conditional that will do something >>> based on whether or not another module has been loaded? <snip> >>> If someone is using foo module, I want to take advantage of its >>> features and use it in foobar, otherwise, I want to do something else. >>> In other words, I don't want to create a dependency of foobar on foo. >>> >>> My failed search for solving this makes me wonder if I'm approaching >>> this all wrong. >> >> Just try importing foo, and then catch the exception if it's not installed. <snip> > Except I want to use the module only if the main program is using it > too, not just if it's available for use. I think that I found a way in > my follow-up post to my own message, but not sure it's the best way or > conventional.
What is your use case for this behavior exactly? You've piqued my curiosity. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list