Import problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Psymaster

    Import problems

    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?
  • Irmen de Jong

    #2
    Re: Import problems

    Psymaster wrote:
    [color=blue]
    > 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?[/color]

    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

    Comment

    Working...