[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] From * import * and Pygame2exe



On Mon, 18 Jul 2005 05:42 am, andrew baker wrote:
> I'm working on my map data portion of my game engine.  The map is
> broken up into a series of files, each describing a "room".  One
> technique I've considered to make loading them easier is to import
> them as a module using "from", such as "from roomxy import *", with
> the roomxy being a dynamic path to module.  Then, each time the player
> enters a room, the new room module is imported, overriding the older
> imported data.

Modules, once imported, stay in memory. You may not want this (otherwise, why 
not just import them at startup?)

Something I learnt a long time ago (the hard way) was that Python's module 
loading mechanisms are really good for loading modules and organising them. 
Python's exec() and execfile() functions are really good for running 
arbitrary python code. Don't use one where you can use the other :)


    Richard

Attachment: pgpCiewBrPD5q.pgp
Description: PGP signature