global variables in imported modules

2010-05-16 Thread vsoler
Taken from www.python.org, FAQ 2.3 How do I share global variables across modules? config.py: x = 0 # Default value of the 'x' configuration setting mod.py: import config config.x = 1 main.py: import config # try removing it import mod print config.x The example, such as shown in

Re: global variables in imported modules

2010-05-16 Thread Patrick Maupin
On May 16, 4:42 pm, vsoler vicente.so...@gmail.com wrote: Taken fromwww.python.org, FAQ 2.3 How do I share global variables across modules? config.py: x = 0   # Default value of the 'x' configuration setting mod.py: import config config.x = 1 main.py: import config       # try

Re: global variables in imported modules

2010-05-16 Thread Rhodri James
On Sun, 16 May 2010 22:42:40 +0100, vsoler vicente.so...@gmail.com wrote: Taken from www.python.org, FAQ 2.3 How do I share global variables across modules? config.py: x = 0 # Default value of the 'x' configuration setting mod.py: import config config.x = 1 main.py: import config

Re: global variables in imported modules

2010-05-16 Thread vsoler
On 17 mayo, 00:05, Patrick Maupin pmau...@gmail.com wrote: On May 16, 4:42 pm, vsoler vicente.so...@gmail.com wrote: Taken fromwww.python.org, FAQ 2.3 How do I share global variables across modules? config.py: x = 0   # Default value of the 'x' configuration setting mod.py:

Re: global variables in imported modules

2010-05-16 Thread James Mills
On Mon, May 17, 2010 at 8:26 AM, vsoler vicente.so...@gmail.com wrote: However, can I be 100% sure that,no matter how I access variable 'x' (with config.x or mod.config.x) it is always the same 'x'. I mean that either reference of 'x' points to the same id(memory position)? Yes it does unless

Re: global variables in imported modules

2010-05-16 Thread vsoler
On 17 mayo, 00:38, James Mills prolo...@shortcircuit.net.au wrote: On Mon, May 17, 2010 at 8:26 AM, vsoler vicente.so...@gmail.com wrote: However, can I be 100% sure that,no matter how I access variable 'x' (with config.x or mod.config.x) it is always the same 'x'. I mean that either

Re: global variables in imported modules

2010-05-16 Thread Patrick Maupin
On May 16, 5:38 pm, James Mills prolo...@shortcircuit.net.au wrote: On Mon, May 17, 2010 at 8:26 AM, vsoler vicente.so...@gmail.com wrote: However, can I be 100% sure that,no matter how I access variable 'x' (with config.x or mod.config.x) it is always the same 'x'. I mean that either

Re: global variables in imported modules

2010-05-16 Thread vsoler
On 17 mayo, 00:52, Patrick Maupin pmau...@gmail.com wrote: On May 16, 5:38 pm, James Mills prolo...@shortcircuit.net.au wrote: On Mon, May 17, 2010 at 8:26 AM, vsoler vicente.so...@gmail.com wrote: However, can I be 100% sure that,no matter how I access variable 'x' (with config.x or