# Module functions logic depend on whether the third party library is used or not

**URL:** <https://discourse.julialang.org/t/module-functions-logic-depend-on-whether-the-third-party-library-is-used-or-not/75266>\
**Category:** General Usage\
**Created:** [January 27, 2022, 2:50am UTC](https://discourse.julialang.org/t/module-functions-logic-depend-on-whether-the-third-party-library-is-used-or-not/75266 "2022-01-27T02:50:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)\
**Post date:** [January 27, 2022, 2:50am UTC](https://discourse.julialang.org/t/module-functions-logic-depend-on-whether-the-third-party-library-is-used-or-not/75266/1 "2022-01-27T02:50:34Z")

</div>

Hi,

I’m pretty new in Julia.

My module `MyModule` consist of few functions and the behaviour of these functions may vary dependent whether the python package is installed or not (I’m going to use PyCall). I think I should introduce something like a global variable `glob USE_PYTHON_LIB = true` and within my functions I shuld implement something like:

```julia
module MyModule

try 
  SN = pyimport("sum_numbers")
  print("use python lib")
catch
  print("not use python lib")
end

function foo(x, y)
  if isdefined(MyModule, :SN)
    return = SN(x,y)
  end
x+y
end

end

```

Then when user executes `using MyModule` the `SN` variable should only be defined if the python module exist.

I think this should works but what is the best practice? Will the perfomance will critically suffer if I put `isdefined()` within loops in my functions?

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [January 27, 2022, 8:09am UTC](https://discourse.julialang.org/t/module-functions-logic-depend-on-whether-the-third-party-library-is-used-or-not/75266/2 "2022-01-27T08:09:22Z")

</div>

You could do

```julia
foo = isdefined(MyModule, :SN) ? SN : (x,y)->x+y

```

and then no checking is performed inside loops
