On Dec 26, 1:09 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 24 Dec 2007 17:14:58 +0100, Martin P. Hellwig wrote: > > As Dennis already pointed out I like to use dictionaries in these cases, > > so I would use sand = dict() instead of sands = list() and would do > > sand[i] = pygame.image.load(name) > > > Then you can retrieve the content by doing sand[your_number]. > > If the keys are just the integers 0...n inclusive, then why bother with > the extra overhead of a dict when you get all the functionality you need > from a list?
The keys aren't integers 0...n here, they're 1, 2, 3, 4, L, R, T, D, TL, TR, BL, BR in the code, so a dict is preferable to a list. Incidentally Katie: is 'D' a typo? It should be 'B' for consistency. Also, functions can be passed arguments, and doing so is preferable to passing information via global variables. So def LoadMaterial(loader): ... sand = LoadMaterial('Sand') Is a lot better than def LoadMaterial(): ... code using 'loader' loader = 'Sand' sand = LoadMaterial() -- http://mail.python.org/mailman/listinfo/python-list