[Tutor] Global presets ?

Alan Gauld wrote:
>>have you considered making the root directory an environment variable?
>That way you can read the value (os.getenv) at the start of the
>script.
>And if you ever need to move the structure you can simply change the
>environment value. It also means different users can use their own
>structures by defining their own environment value...
>>>>############
># File myvars.py
>value1 = 42
>value2 = 'spam'
>>>Got ya so far ..
>#############
># File: prog1.py
>>import myvars
>>localvar = myvars.value1
>myvars.value2 = 'Alan'
>>>Never thought of setting 'myvars.value2 = 'Alan'' I guess this would
just set the variable in the myvars namespace since it could not change
myvars.py itself.
>##############
># File prog2.py
>>import myvars
>>newvar = myvars.value2
>>
With you ...
>print myvars.value1 - 27
>>Have I misunderstood, should this not be 42 ? Typo or me not understanding ?
>##############
>>Does that help?
>>Alan G
>Author of the Learn to Program web tutor
>http://www.freenetpages.co.uk/hp/alan.gauld>>>>>