[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] taming the circus of modules
- To: pygame-users@seul.org
- Subject: [pygame] taming the circus of modules
- From: Pete Shinners <pete@visionart.com>
- Date: Fri, 04 Jan 2002 15:31:40 -0800
- Delivered-To: archiver@seul.org
- Delivered-To: pygame-users-outgoing@seul.org
- Delivered-To: pygame-users@seul.org
- Delivery-Date: Fri, 04 Jan 2002 18:33:08 -0500
- Reply-To: pygame-users@seul.org
- Sender: owner-pygame-users@seul.org
- User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.7+) Gecko/20020104
if you haven't noticed, there are currently a lot of modules included in
the pygame package. things have actually grown a little out of hand
recently, so i've got some plans to put things under control.
originally, running "import pygame" would import all the standard
(non-optional) modules for pygame. then if a user wanted any of the
optional modules, they would import them by hand.
recently i've been adding several modules to pygame. most of the new
modules are not optional, but still aren't being imported by default.
thus the code to import pygame starts to look pretty beastly. take a
look from the chimp example...
import pygame, pygame.sprite, pygame.transform, pygame.image
from pygame.locals import *
try:
import pygame.font
except ImportError:
print 'Warning, fonts disabled'
pygame.font = None
try:
import pygame.mixer
except ImportError:
print 'Warning, sound disabled'
pygame.mixer = None
this doesn't please me at all, but it's the proper way to import
everything pygame needs, but still cleanly exit if one of the optional
modules does not exist.
therefore...
my plan is this, "import pygame" will import all the pygame modules. if
an optional module is not present, it will be assigned "None" (sort of
like what happens above in the chimp example.
with this method, we will clean up all the ambiguous issues with which
modules are included and which are manual. checking for the existance of
"optional" modules can be moved to a simple "if" statement, and life in
general will require ~10 less lines of code.
the good news is, this change should not break any code (that i can
think of). if this sort of change does look like it will cause problems
for you, or you have a slightly better idea, now is the time to speak up.
(as a side note, i will be striking the "UserRect" module from the
library. no tears, please)
also as an optional idea, i may include the "pygame" variable inside the
little "locals" module. then everything could be imported exactly the
same by doing "from pygame.locals import *", and nothing extra needed.
(to clarify, you would still access everything as "pygame.display", not
just "display"). comments?
for fun, the current list of modules goes like this...
cdrom, constants, cursors, display, draw, event, font, image, joystick,
key, mixer, mouse, movie, sprite, time, transform, version
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org