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

Re: [pygame] "Try" For World Loading



In a message of Sun, 20 Nov 2005 07:30:23 +0100, Laura Creighton writes:
>In a message of Sun, 20 Nov 2005 00:16:57 EST, Kris Schnee writes:
>>I'm working on a system for loading parts of the game world as "zones" 
>>with names determined by coordinates. If the player moves outside a 
>>zone, the game will look for a zone with a certain name to load it. But 
>>the file for that zone might not exist. I'm about to write the function 
>>so that it uses the "try" statement to look for the file. Is that bad 
>>for some reason, or even "bad form?" Is there a reason to do things a 
>>different way, namely looking at a list of all files and saying "if 
>>desired_filename in list_of_files, load?"
>>
>>Kris
>
>The first way you suggested is the preferred form, the second way
>is 'not Pythonic'.  see: http://groups.google.se/group/comp.lang.python/b
>rowse_thread/thread/66083a5d944ceb9b/a0dd5e0ae60efdce?lnk=st&q=%22Look+Be
>fore+you+leap%22+author%3AAlex+author%3Amartelli&rnum=16&hl=sv#a0dd5e0ae6
>0efdce
>
>(or go to Google groups and Google comp.lang.python for 
>'Look before you Leap'.  Alex Martelli likes talking about why this is
>usually not such a good idea.)
>
>A good reason to do it would be that what you are wrapping your try aroun
>d
>takes such an enormous long time to fail that it makes your game
>lurch around like a zombie.  If you aren't looking for your files on
>a local disk, say, but have to make an request over the internet,
>this could be a problem for you, depending on how fast it takes the
>other end to serve up the files.
>
>Laura

Actually, I meant 'depending on how fast it takes the other end
to serve up the message: that file is not here', thus validating the
principle that posts to the internet made before your first cup of
tea in the morning are never correct.

sorry about that,
Laura