OMG please help
Martin P. Hellwig
xng at xs4all.nl
Tue Dec 25 20:57:17 EST 2007
Steven D'Aprano 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?
>
>
>
Just a matter of preference in my case no other good reason. Although I
do have a tendency to misuse dict all over the place, but on the other
hand it keeps my stuff readable for others :-)
--
mph
More information about the Python-list
mailing list