[Tutor] how to tell if strings have numbers in them

Moshe Zadka moshez@zadka.site.co.il
Thu, 4 Jan 2001 19:20:26 +0200 (IST)

On Wed, 03 Jan 2001 18:14:18 -1000, Brett <brett42@flex.com> wrote:
> I'm trying to get input and checking to see if it's a number.  x==int(x) 
> works if it is a number, but causes an error if you input a string.  I made 
> a list of 0-9 and tried for z in x/if z in list, and that seems to work, 
> but its takes a lot of typing, is there an existing function that can check 
> to see if a variable is a number?

I usually use:

import re

is_integer = re.compile('[0-9]+').match

I'm not sure what you mean by a number (float? scientific notation? negative?)
Moshe Zadka <sig@zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!