Import problems

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sat Jan 3 13:33:21 EST 2004


Psymaster wrote:

> I'm working on projects using pygame and I encounter the following 
> problem: In (almost) every file of my source I have to "include 
> pygame" because every file uses some function from pygame. Is there 
> another way to do this? Does it provide overhead to my app?

There is no overhead. Modules get imported only once.
Any  additional imports just return the same module directly.

But there should be another way to do this; if all your files
depend on pygame, I think the modularization / structure of your
program is suboptimal. I think there should only be a few
modules that do stuff related to pygame, the rest should import
those instead of doing things via pygame themselves.

--Irmen




More information about the Python-list mailing list