Are you planning to load it if it isn't already loaded? If so, there's no need to check--modules should only be loaded once, even if they're used/imported more than once.
Cheers, Kevin On Wed, Apr 30, 2014 at 3:09 PM, Matt Bauman <[email protected]> wrote: > Is there a robust way to test if a Module has already been imported? Some > modules take a very long time to load, and in some contexts it might be > nicer to check to see if the functionality is there before spending 30 > seconds loading it and all its dependencies. > > The naive :FooModule in names(Main) fails if I reference FooModule later > in the same namespace. I can get around that by adding another scope (like > a macro or secondary function), but that's a bit of a pain. Is there a > better way? > > julia> f() = :FooModule in names(Main) && (println("has FooModule"); > FooModule.bar()) > f (generic function with 1 method) > > julia> f() > has FooModule > ERROR: FooModule not defined > in f at none:1 >
