Ad

Importing One Module From Another Module

- 1 answer

I am importing one module from another module so I am using below syntax

if __name__ == '__main__':
    main()
    try:
        print("sorry We can't Let use this module To another Framework :")
    except Exception:
        print("yup")
    sys.exit(0)

How to stop preventing importing one module from another module so that whenever I call previous module it will run sys.exit(status) and module import process will fail?

Ad

Answer

#think i found better solution myself 
#so what if i write operation stuffs after calling main() #instead of writing those in main method like an example

def main() :
    return 

if  __name__=='__main__' :
     main() #calling main
   #todo operation stuffs#####

#Note: So if this module call by another module then it won't provide any operation stuffs just because main function has nothing to return. But in this module after calling main rest of the operations will start executing
Ad
source: stackoverflow.com
Ad