[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

imported var not being updated

Alex Hall

3/9/2010 4:22:00 AM

Hello all:
I have a project with many pyw files. One file holds a variable and a
function that I find myself using across many other pyw files, so I
called it helpers.pyw. The variable is "mostRecent", which is a string
and is meant to hold a string so I know what the program most recently
output; in all the other pyw files, every time the program outputs
something, I include the line
helpers.mostRecent=output
where output is a string and helpers has been imported.

The problem is that mostRecent does not seem to be updated at all, and
I cannot figure out why. I declare it with empty quotes initially, but
the program should keep updating it. Everytime I go to see what its
value is, though, it is still apparently empty. Here is a basic
sample:

randomFile.pyw
---
import helpers

def something():
output="I am the most recently output string!"
helpers.mostRecent=output
#end def

file2.pyw
---
from helpers import mostRecent

print(mostRecent) #prints nothing

Any thoughts on what I am doing wrong? Thanks!!

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.c...