problem updating variable in a module
dudeja.rajat at gmail.com
dudeja.rajat at gmail.com
Wed Sep 24 11:22:47 EDT 2008
Thanks Tim,
Yes, I mean 'mod' only.
But this does not work for me
On Wed, Sep 24, 2008 at 4:19 PM, Tim Rowe <digitig at gmail.com> wrote:
> 2008/9/24 <dudeja.rajat at gmail.com>:
> > 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
> >
> > mod1
> > ********
> > a = 10
> > def update(someInt):
> > global a
> > a = someInt
> > print a <---- this does actually print a = 20
>
> I'm surprised it runs at all -- as far as I can see "mod" in
> "mod.update(a)" and "print mod.a" is not defined. Did you mean "mod1"?
> If I change it to that, both print statements print "20" as I'd
> expect.
>
> I take it you do have a *really* good reason to use a global?
>
> --
> Tim Rowe
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Regrads,
Rajat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080924/8c91666a/attachment-0001.html>
More information about the Python-list
mailing list