johnny <[EMAIL PROTECTED]> wrote:

> 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():
> 
> 
> thnx.
> 
> 

Yes;by using its name;global scope.

Why not try it for yourself?

N.B. Functions in Python do not exist until the def statement is executed, 
so the code like your sample will fail to find 'main' if you try to call it 
from inside the class body. A call from inside an instance method would be 
fine though (provided you didn't call it until main was defined), or a call 
from the class body would also be fine provided you define main before you 
define the class.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to