globals accros modules
Stef Mientki
S.Mientki-nospam at mailbox.kun.nl
Thu Jan 11 13:42:53 EST 2007
Bruno Desthuilliers wrote:
> stef a écrit :
>>
>>>
>>> Change a=1 to amodule.a=1
>>> If you find yourself doing tricks with the module globals, think
>>> about redesigning your application.
>>>
>> Of course I completely agree with you.
>>
>> But ...
>> if you're moving from MatLab to Python,
>> and want to show your collegaes,
>> with how little effort they can reuse all their existing MatLab
>> routines in Python,
>> then the global issue is a real pain !!
>>
>> You can explain your collegaes, that
>> - the startindex of arrays changes from 1 to 0
>> - slices are upto, instead of including the final border
>> - indention is thé key
>> And tell them about all beautiful things in Python,
>> but tell them that they are going to loose all their globals ???
>
> It's a feature. Globals are definitively a BadThing(tm).
yes, I know, but my audience will accept that only in the long term.
But maybe this idea works:
<file Ugly_MatLab_Globals.py>
global var1
global var2
</file Ugly_MatLab_Globals.py>
<all other py-files in the project>
import Ugly_MatLab_Globals
def some_function():
import Ugly_MatLab_Globals
</all other files in the project>
(btw who owns the BadThing tm ;-)
cheers,
Stef Mientki
More information about the Python-list
mailing list