On 04/08/2020 20:38, Steve wrote:
Why should line 6 fail until line 7 is commented out?
Python complains that MSN is "referenced before assignment".
def ReadTheEQfile():
global MSN
MSN = ("1 Monitor") #This line works every time.
def EditTheEQlist():
print("MSN2 = " + MSN) # Work
that's a
different function. 'global' applies only to the function it's used in.
From: Souvik Dutta
Sent: Tuesday, August 4, 2020 5:12 AM
To: Steve
Subject: Re: Updating a variable problem.
I don't know your exact meaning of fail. But as much as I can say there is
.
FootNote:
If money does not grow on trees, then why do banks have branches?
From: Souvik Dutta
Sent: Tuesday, August 4, 2020 5:12 AM
To: Steve
Subject: Re: Updating a variable problem.
I don't know your exact meaning of fail. But as much as I can say there is a
new variable MSN
Probably because the MSN variable in the second function is not global.
On Tue, Aug 4, 2020, 2:08 PM Steve wrote:
> Why should line 6 fail until line 7 is commented out?
> Python complains that MSN is "referenced before assignment".
>
> def ReadTheEQfile():
> global MSN
> MSN = ("1 Monitor")
Why should line 6 fail until line 7 is commented out?
Python complains that MSN is "referenced before assignment".
def ReadTheEQfile():
global MSN
MSN = ("1 Monitor") #This line works every time.
def EditTheEQlist():
print("MSN2 = " + MSN) # Works if the next line is commented out.
MS