thecocce / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Global variable bug #420

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a module and declared global variable then create function in module 
and declared global to the same variable name.
2. Saw some variables are global in function and some are local although all 
were declared as global variable.
3.

What is the expected output? What do you see instead? When declared a variable 
and passing value in module top saw variable was global. When declared same 
variable name as global in function also inside the module and saw variable 
still has local status.

What version of the product are you using? On what operating system?it was 
pyscripter 1.9. I use win XP 32 bits.

Please provide any additional information below.

Original issue reported on code.google.com by chanh.q....@gtempaccount.com on 22 Sep 2010 at 9:13

GoogleCodeExporter commented 9 years ago
I am not sure I understand. Are you referring to something like this?
x = 0
def f():
  global x
  x = 2 
f()
print x

So what is the issue?  PyScripter just uses standard python to compile and run 
the code, so if it works in Python it should work in PyScripter.  Can you 
provide an example?

Original comment by pyscripter on 22 Sep 2010 at 10:05

GoogleCodeExporter commented 9 years ago
I tried on simple things as you proposed before I poet the bug report and I saw 
simple example like that works. However, I sent the code to you so you can view 
in depth to understand the bug that I am facing

Original comment by chanh.q....@gtempaccount.com on 22 Sep 2010 at 10:53

GoogleCodeExporter commented 9 years ago
Which code? I do not see any attachments.

Original comment by pyscripter on 23 Sep 2010 at 1:12

GoogleCodeExporter commented 9 years ago
Seem like reply through email did not go through. Here is attached file.

Original comment by chanh.q....@gtempaccount.com on 23 Sep 2010 at 4:47

Attachments:

GoogleCodeExporter commented 9 years ago
OK.  I loaded your file into PyScripter.  I cannot run it since I do not have 
the required modules.  So, what is the issue?

By the way AFAIK the global statement makes no sense at the module level, so I 
cannot see the purpose of 

global  SourceDirectory
global  InputFolder
global  ITPScriptsFolder
global  TestsFolder
global  TxBaseSpecThreadStatus1,TxBaseSpecThreadStatus2,WaveformCount

etc.

Original comment by pyscripter on 23 Sep 2010 at 7:44

GoogleCodeExporter commented 9 years ago
Is this related to issue 421?  Is the issue that the information displayed when 
the mouse hovers over a variable is incorrect?

Original comment by pyscripter on 23 Sep 2010 at 7:49

GoogleCodeExporter commented 9 years ago
Thanks, my friend told me do not use global statement at top because they 
already global.
Use global statement in a function of moduleA. Then at different moduleB use 
import moduleA then use moduleA.variablename, value will get through 

Original comment by chanh.q....@gtempaccount.com on 23 Sep 2010 at 9:28