Testing if a variable is an integer or a string; exceptions in __del__

Fredrik Lundh fredrik at pythonware.com
Mon May 3 06:02:47 EDT 1999


Ben Gertzfield <che at debian.org> wrote:
>What's the best way to test if a variable is numeric or a string?
>I'd like to be able to test my Id3 module with some command-line
>options, one of which denotes the genre of the file.

and later he wrote:

> Aren't using exceptions a lot of overhead, though?

not if they're not raised.  and I doubt that you'll
notice the difference in this case...

(premature optimisation is the root etc etc)

here's one optimization you might wish to consider,
though: use "int" instead of "string.atoi" (that'll save
you 8 keystrokes!)

</F>





More information about the Python-list mailing list