Pythonic way to determine if a string is a number

Mel mwilson at the-wire.com
Mon Feb 16 01:05:36 CET 2009


Christian Heimes wrote:
> Roy Smith wrote:

>> They make sense when you need to recover from any error that may occur,
>> possibly as the last resort after catching and dealing with more specific
>> exceptions. In an unattended embedded system (think Mars Rover), the
>> top-level code might well be:
>> 
>> while 1:
>>    try:
>>       main()
>>    except:
>>       reset()
> 
> Do you really want to except SystemExit, KeyboardInterrupt, MemoryError
> and SyntaxError?

Exactly.  A normal program should never do anything more comprehensive than

try:
    some_function ()
except StandardError:
    some_handling ()

IMHO

        Mel.




More information about the Python-list mailing list