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
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
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
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
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() :
>>
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
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
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
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
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
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
11 matches
Mail list logo