Global package variable, is it possible?

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Aug 6 11:27:01 CEST 2007


Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com> writes:

> I've read all the thread, and it seems that your problem is mostly
> to share a single dynamic state (the config) between several
> modules. So I do wonder: have you considered the use of the
> Singleton pattern (or one of it's variants...) ?

Python modules are effectively singletons. So the idiomatic way to do
this is to create a module for configuration (perhaps named 'config'),
import that into every other module that needs it, and use its
attributes.

-- 
 \       "[On the Internet,] power and control will shift to those who |
  `\       are actually contributing something useful rather than just |
_o__)                                 having lunch."  -- Douglas Adams |
Ben Finney



More information about the Python-list mailing list