sort of a beginner question about globals

Steven Bethard steven.bethard at gmail.com
Wed Apr 13 00:32:28 EDT 2005


fred.dixon wrote:
> i have read the book and searched the group too
> ----------------------------------------------
> im not gettin it.
> i want to read a global (OPTIONS) from file1 from a class method
> (func1) in file2
> i want to understand how this works.
> 
> ----------------------------------------------
> #file1.py
> import file2
> import sys
> 
> OPTION = sys.argv[1:]
> pass
> a=global2.class1()
> a.func1()
> 
> 
> #file2.py
> import __main__
> pass
> class class1:
> .    def func1(self):
> .        pass
> -------------------------------------------

----- file1.py -----
import file2

a = file2.class1()
a.func1()
--------------------

----- file2.py -----
class class1(object):
     def func1(self):
         pass
--------------------

I don't see what you want OPTION for, so I've removed it.  If you can 
explain your intentions better, maybe I can help more.

STeVe



More information about the Python-list mailing list