include in python
Bartek Golenko
bartek at debian.caton.com.pl
Mon May 5 06:00:38 EDT 2003
Irmen de Jong <irmen at -NOSPAM-REMOVETHIS-xs4all.nl> wrote:
>> I want to divide my program into smaller files, but I would prefer not
>> to use import (as it results in a separate namespaces for each module and
>> there are some interactions between them that I do not wish to cope with
>> right now).
>
> You should, eventually. Fire up a python shell and type "import this"
> and read the last line :-)
Nice ;)
Well, the program I'm writting now is a prototype so it's going to be
rewritten anyway, but right now I just want a convinient way to split
the source code into smaller chunks.
> Anyway, you could do
>
> from your_module import *
# prog.py
from xxx import *
def hello():
print "Hello..."
# xxx.py
hello()
It will not work unless I do
# xxx.py
import __main__
__main__.hello()
Which is sth I really want to avoid ;)
--
Bartlomiej Golenko
bartek at zts.ita.pwr.wroc.pl
More information about the Python-list
mailing list