Computer Science

A function checkMain() defined in module Allchecks.py is being used in two different programs. In program 1 as Allchecks.checkMain(3, 'A') and in program 2 as checkMain(4, 'Z'). Why are these two function-call statements different from one another when the function being invoked is just the same ?

Python Libraries

1 Like

Answer

Allchecks.checkMain(3, 'A') and checkMain(4, 'Z') these two function-call statements are different from one another when the function being invoked is same because in Allchecks.checkMain(3, 'A') statement, Allchecks.py module is imported using import Allchecks import statement in a new namespace created with the same name as that of module name and hence they are called by dot notation whereas in checkMain(4, 'Z') statement Allchecks.py module is imported using from Allchecks import checkMain import statement in the current namespace and hence its module name is not specified along with the function name.

Answered By

1 Like


Related Questions