[Glade-users] Global variables



I've had a problem with global variables for the past few months, but haven't been able to find a solution. 
I'll give a simplified example of what it is, then I'll go into more detail

Imagine if you have one module, example.py:

global money
money=100

def wife_spends_money():
??? global money
??? money-=1



def husband_spends_money():

??? global money

??? money-=1

now lets say there are also 1000 other functions for the husband, and 1000 for the wife, and example.py grows 
out of control, so we split it up into three modules:

wife.py



def wife_spends_money():

??? global money

??? money-=1

husband.py






def husband_spends_money():


??? global money


??? money-=1


example.py

from wife import *
from husband import *

global money

money=100

But the problem is money is not global to either husband.py or wife.py, how do I properly implement this? 
Passing all the globals from example.py to wife.py will work, but it's not good programming.

The issue arises from the fact that glade puts all the callbacks into one file, and it is INCREDIBLY long, I 
would much prefer to break it up into multiple files, but the global variables, declared in the init() 
function, are presenting a barrier.

Thank You


Peyman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20081113/be3f05db/attachment.html 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]