Re: Updating a variable problem.

2020-08-04 Thread dn via Python-list
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

Re: Updating a variable problem.

2020-08-04 Thread MRAB
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

RE: Updating a variable problem.

2020-08-04 Thread Steve
. 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

Re: Updating a variable problem.

2020-08-04 Thread Souvik Dutta
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")

Updating a variable problem.

2020-08-04 Thread Steve
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