Re: problem updating variable in a module

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Reedy

    Re: problem updating variable in a module

    dudeja.rajat@gm ail.com wrote:
    Hi,
    >
    I've a problem updating my variable in a module.
    >
    In my main program, I call a function from mod1 to update a variable of mod1
    As soon as I update this varibale, I check it back in the mail program
    but it the variable from mod1 does not get updated.
    >
    main Program:
    *************** *
    import mod1
    a = 20
    mod.update(a)
    print mod.a <---- does not print anything
    As Tim noted, this cannot run.
    *** Always post the code you actually ran ***
    So we cannot answer why the code you did not post did not work.

    With the mod/mod1 mixup fixed, you do not need the update function.
    mod.a = 20
    should do the same thing.
    >
    mod1
    ********
    a = 10
    def update(someInt) :
    global a
    a = someInt
    print a <---- this does actually print a = 20
    tjr

Working...