Pythonic way to determine if a string is a number
Tino Wildenhain
tino at wildenhain.de
Mon Feb 16 02:18:42 EST 2009
Roy Smith wrote:
> In article <gnaak5$1nek$1 at services.telesweet.net>,
> Mel <mwilson at the-wire.com> wrote:
>
>> 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?
>
> Absolutely. Let's take my example -- you're writing software for a Mars
> Rover. I have no idea how you might get a MemoryError, but let's say you
> do. Which would you rather do, perform a system reset, or print a stack
> trace and wait for a friendly Martian to come along and reboot you?
>
> You may think I'm being silly, but I'm dead serious. The many layers of
> "It's impossible for this to happen, but if it does let's do something to
> try and recover" processing saved that mission several times over. In some
> applications, there's no such thing as "halt".
Yeah, having your mars rower forever running in a loop to try to convert
some random string to a number is sure something you want to achieve.
Tino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090216/2320303f/attachment-0001.bin>
More information about the Python-list
mailing list