Python, global function
Problem
1) One want to organize the code using modules (files)
2) One wan packages to see other packages (at least a global function that is aware of all the definition of classes and can be used by all module)
3) One can not using from xx import * in every package
The solution is dynamic importing (which is one of the beauty of Python)
We can
1) define the global function, say, isa() in __ini__.py in the package's root directory
2) import in the METHOD (not __init__ method or as a module import) where you want to use.
No comments:
Post a Comment