1

I've designed a package that requires another python package, but there are some in my group that would like to make this package optional.

Does anyone have any suggestions/best practices on how handle optional packages?

I was thinking of doing this:

try:
    import package
    allowFunctions = True
except:
     allowFunctions = False

Is this the best way to do handle package checking?

To make this not a duplicate, which I think it isn't, where should the check occur in the package? Should it occur int he main init.py for the package folder? Can all the other subpackages/modules pull from that init.py file the checked variable name?

code base 5000
  • 3,812
  • 13
  • 44
  • 73

0 Answers0