In article <11**********************@q75g2000hsh.googlegroups .com>,
johnny <ra*******@gmail.comwrote:
Can a class inside a module, access a method, outside of class, but
inside of the module?
Eg. Can instance of class a access main, if so how? What is the
scope of "def main()" interms of class A?
myModule:
class A:
main()
def main():
Yes, class A can access main. The name "main" will be defined at the
top level of the module, and is considered a global for that module.
Code within that module can access it simply as "main". Code in other
modules would have to import the module in order to use symbols within
it. For example...
### myModule.py ####
class A:
def m():
main()
def main():
pass
### other.py ###
import myModule
def main():
pass
class B:
def o():
main() # calls main() in this module
myModule.main() # calls main in myModule
Dave