[Tutor] Modules - problem

Magnus Lycka magnus at thinkware.se
Thu Oct 17 12:10:28 EDT 2002


Have a look at the documentation for reload and
__import__ (Library reference section 2.1)

It's probably easier for us to be helpful if you
tell us what you are trying to achieve. There might
be other options that are more relevant, like openinig
a file and running exec (or rexec) on the contents, or
using the ConfigParser module.

You can import files with non-typical filenames using
the imp module (see Lib Ref 3.21), but AFAIK that mean
that no compiled version will be saved. (.pyc)

At 15:08 2002-10-17 +0200, A wrote:
>Hi,
>I would like to access a variable in one module from another module.For 
>example
>
>The main module is like this
>#############
>#Main modul z1.py
>import z3
>print "x variable=", z3.x
>###########
>
>where z3.py module is like
>
>########
>#My module z3.py
>global x
>x=11
>#########
>Now if I run z1.py for the first time it prints properly
>
>x variable= 11
>
>but if I do any  change in z3 module , it has no effect
>For example If I change in z3
>x=12
>I still get
>  x variable= 11
>Why?
>Thank you for help.
>Is it possible to name module with a different extension from py? For 
>example is it possible
>to import z3.cod file?
>Ladislav
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor

-- 
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se





More information about the Python-list mailing list