On Jul 23, 2007, at 10:45 PM, MB Software Solutions wrote:

>>      Start coding in Python, where 'try' blocks are routine, since in
>> many cases it's faster to catch an exception than to test for a
>> condition.
>>
>
> "Faster" because it's fewer lines of code?

        Not at all. Faster because checking for the existence a particular  
attribute (the 'hasattr()' function) takes a finite amount of time.  
Since 99.9999% of the time it will return True (the False condition  
only happens at startup/shutdown), that time is wasted. The try/ 
except construction allows the call to be made directly, but handles  
the few outlier conditions without crashing the program.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to