[Tutor] visibility of variables

Victor Reijs genietdev0 at iol.ie
Mon Aug 1 18:41:12 CEST 2005

Hello all of you,

I have problems with the visibility of variables in python. I am
used to the idea of Javascript and other languages where one can define
global variables if they are defined outside a function. It seems Python
is not doing that, but how can I make it work?

I think it needs some twist in my mind to get used to it, but I still
don't grasp it. Can you help?

I have attached a program that is not functioning as I would like to
have it functioning.
It seems that the 'gementenkleur' in funct1 and funct2 are the value of
gemetenkleur at the start of the program, but they don't chance after
the definition of gemetenkleur=bmifrao1.bmp

I 'know' this is something particular to Python, by how can I work
around this? I could add gemetenkleur in the argument list of the funct1
and funct2 functions, but in my case I don't want this (funct1 will be a
function to be used in scipy.fmin, and I have the idea that only the
simplex can be as an argument).

Is there a good page on the web that described this visibility issue (or
does it have a different name?) of Python? The delveintopython.pdf does
not help me and also a tutorial of hetland.org (Instant python:
instant-python.php.htm ) seems not to speak the right language for me;-).

Hope someone can help me. I have the idea this is essential to
understand before continuing more in Python.

All the best,


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: visibility.py
Url: http://mail.python.org/pipermail/tutor/attachments/20050801/480fbe19/visibility.diff

More information about the Tutor mailing list