Inter-module globals

Schüle Daniel uval at rz.uni-karlsruhe.de
Thu Mar 9 08:31:34 EST 2006


Anton81 wrote:
> Hi,
> 
> I want to use globals that are immediately visible in all modules. My
> attempts to use "global" haven't worked. Suggestions?
> 
> Anton

I think a dictionary would work here
as well as list but not strings and int's

# module1
settings = {
	"release" : "1.0",
	"blabla"  : None,
}

# module2
import module1 as settings
print settings.settings["release"]
settings.settings["blabla"] = True


# module3
import module1 as settings
settings.settings["blabla"] = False

Regards




More information about the Python-list mailing list