Re: global vars across modules

2012-04-25 Thread Thomas 'PointedEars' Lahn
John Nagle wrote: > On 4/22/2012 12:39 PM, mambokn...@gmail.com wrote: >> Question: >> How can I access to the global 'a' in file_2 without resorting to the >> whole name 'file_1.a' ? > > Actually, it's better to use the fully qualified name "file_1.a". > Using "import *" brings in everythin

Re: global vars across modules

2012-04-22 Thread Chris Angelico
On Mon, Apr 23, 2012 at 8:13 AM, Kiuhnm wrote: > It makes sense though. > "Import" imports values, not variables. Python doesn't _have_ variables. Python has names and objects. http://python.net/~mwh/hacks/objectthink.html ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: global vars across modules

2012-04-22 Thread Kiuhnm
On 4/22/2012 23:08, Kiuhnm wrote: On 4/22/2012 21:39, mambokn...@gmail.com wrote: I need to use global var across files/modules: # file_1.py a = 0 def funct_1() : a = 1 # a is global print(a) # file_2.py from file_1 import * def main() : funct_1() a = 2 # a is local, it's not imported print(a

Re: global vars across modules

2012-04-22 Thread John Nagle
On 4/22/2012 12:39 PM, mambokn...@gmail.com wrote: Question: How can I access to the global 'a' in file_2 without resorting to the whole name 'file_1.a' ? Actually, it's better to use the fully qualified name "file_1.a". Using "import *" brings in everything in the other module, which o

Re: global vars across modules

2012-04-22 Thread Dave Angel
On 04/22/2012 05:08 PM, Kiuhnm wrote: > On 4/22/2012 21:39, mambokn...@gmail.com wrote: >> I need to use global var across files/modules: >> >> # file_1.py >> a = 0 >> def funct_1() : >> a = 1# a is global >> print(a) >> >> >> # file_2.py >> from file_1 import * >> def main() : >>

Re: global vars across modules

2012-04-22 Thread Kiuhnm
On 4/22/2012 21:39, mambokn...@gmail.com wrote: I need to use global var across files/modules: # file_1.py a = 0 def funct_1() : a = 1 # a is global print(a) # file_2.py from file_1 import * def main() : funct_1() a = 2 # a is local, it's not imported p

Re: global vars across modules

2012-04-22 Thread Roy Smith
In article <11146533.5.1335125285850.JavaMail.geo-discussion-forums@pboo1>, mambokn...@gmail.com wrote: > On Sunday, April 22, 2012 12:48:23 PM UTC-7, Roy Smith wrote: > > > Answer 1: You can't. > > > > Answer 2: You might want to look at thread local storage > > (http://docs.python.org/l

Re: global vars across modules

2012-04-22 Thread Chris Angelico
On Mon, Apr 23, 2012 at 6:08 AM, wrote: > Thanks! Here is what I need to do, perhaps you can give me some hints. > > A generic module, used across different independent programs, puts its > computing results in a var fairly big, ~50KB. > > I need the functions in these programs to access that va

Re: global vars across modules

2012-04-22 Thread mamboknave
On Sunday, April 22, 2012 12:48:23 PM UTC-7, Roy Smith wrote: > Answer 1: You can't. > > Answer 2: You might want to look at thread local storage > (http://docs.python.org/library/threading.html#threading.local). > > Answer 3: Are you sure you really want to do this? Thanks! Here is what I

Re: global vars across modules

2012-04-22 Thread Roy Smith
In article <2652842.660.1335123578432.JavaMail.geo-discussion-forums@pbckz3>, mambokn...@gmail.com wrote: > I need to use global var across files/modules: [...] > Question: > How can I access to the global 'a' in file_2 without resorting to the whole > name 'file_1.a' ? Answer 1: You can't. A

global vars across modules

2012-04-22 Thread mamboknave
I need to use global var across files/modules: # file_1.py a = 0 def funct_1() : a = 1 # a is global print(a) # file_2.py from file_1 import * def main() : funct_1() a = 2 # a is local, it's not imported print(a) Here above 'a' is not imported from file_1