Global & Importing issues.... Newbie

Aahz Maruch aahz at netcom.com
Mon Jul 17 13:37:51 EDT 2000


In article <963849878.7647.0.nnrp-13.c3ad12d2 at news.demon.co.uk>,
Toby <t.harris at robinsons.co.uk> wrote:
>I have a simple requirement for a second module to access a global variable
>stored in the first (main) module.
>
>I can reproduce my problem with the following 2 modules...
>
>Mod1.PY >>>
>import Mod2
>
>myGlobal = None
>
>if __name__ == "__main__":
>
>  myGlobal = 100
>
>  Mod2.DoPrint()
>#endif
>#endmodule
>
>
>Mod2.PY >>>
>import Mod1
>
>def DoPrint():
>  print Mod1.myGlobal
>#enddef
>#endmodule

What's wrong with

  Mod2.DoPrint(myGlobal)

?
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Q:  In a lesbian relationship, who decides who gets to be the man?
A:  It's two women.  There is no man.  That's the point.



More information about the Python-list mailing list