Strange compiler warning

Robin Becker robin at jessikat.fsnet.co.uk
Tue Oct 8 15:25:47 EDT 2002


In article <_Yzo9.20199$cG.4769 at fe04>, Steve Holden
<sholden at holdenweb.com> writes
......
>> As for the try except is it really true that
>>
>> try:
>>     _dbg
>> except:
>>     _dbg = .....
>>
>> is better than
>>
>> if not globals().has_key('_dbg'):
>>     _dbg = .....
>>
>Who's to say which is better? They are certainly *different*, since the
>former will pick up _dbg from any of the usual suspects' scope, whereas the
>latter explicitly tests just one single namespace.
>
>When _dbg is declared global (sorry, I was picking nits) then it's perhaps a
>matter of taste (<gasp>, you mean there really *is* more than one way to do
>it?). Who's to say which is faster? Only a timing test will tell you. Was
>speed your criterion for "better"? Even if it's readability, ut's still
>pretty much a matter of taste.
.... I'm just being lazy, I need to put a bunch of debugs in a routine
that gets called more than once, rather than split the debugging prints
into module level and function parts I just want to put them all in one
place.  
-- 
Robin Becker



More information about the Python-list mailing list