Import problems

P

Psymaster

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?
 
I

Irmen de Jong

Psymaster said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,174
Messages
2,570,940
Members
47,486
Latest member
websterztechnologies01

Latest Threads

Top