newb: Python Module and Class Scope
rishi pathak
mailmaverick666 at gmail.com
Thu May 10 10:14:33 EDT 2007
This works for me.Also tried importing this module into another program.
The class is inside the module so like the different function's of a module
can access each other,the same thing applies to a class and
functions/classes
#Test Module
class foo:
def __init__(self):
self.data=1
def outData(self):
print self.data
main()
def main():
print "I am the main"
#Module test
if __name__=="__main__":
fooObj=foo()
fooObj.outData()
On 10 May 2007 07:02:49 -0700, johnny <rampeters at gmail.com> 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.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070510/89f13288/attachment.html>
More information about the Python-list
mailing list