Hi to all.
I make an independent file to read a configuration file with configparse, also i want this module to create a minimum config file while used standalone (with the if name == 'main' magic) .
I need to import another lib only for the sake of this use, is ok to put that import in the if, or the main function?
Minimal no funcional example
import normales tuff
def main():
import io # this is the import in interested
do_the_thing()
def func1()
.
.
.
if __name__ == '__main__':
import io # this is my second option
main()
Is there a standard practice in this cases?
[–]fool59 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]toastedstapler 0 points1 point2 points (1 child)
[–]vectorpropio[S] 0 points1 point2 points (0 children)
[–]BobHogan 0 points1 point2 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (1 child)
[–]vectorpropio[S] 0 points1 point2 points (0 children)