Hi!
I got these extension example. Im passing in a argument squareWidth to the method Size() which I am dividing the global variable resx with.
My question is regarding this global variable.
First I wrote like this but it gave me an error saying that resx is not defined:
[code]class Startup:
resx = 0
def __init__(self):
resx = op('null1').width
print(resx)
return
def Size(self, squareWidth):
print(resx / squareWidth)
return[/code]
Then I wrote it like this instead which worked:
[code]class Startup:
resx = 0
def __init__(self):
global resx
resx = op('null1').width
print(resx)
return
def Size(self, squareWidth):
print(resx / squareWidth)
return[/code]
My question is; in python do I need to redefine a variable as global everytime I change it or are there a better way doing this?
python1.1.toe (3.96 KB)