-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "Lad" == Lad  <[EMAIL PROTECTED]> writes:
Lad> How can I find out in Python whether the operand is integer or a
Lad> character and change from char to int ?

In Python, the canonical way of doing this would be to simply assume
that the argument can be converted to an integer and catch any errors
that occur:

def f(x):
    try:
        x = int(x)
    except ValueError:
        # It's a non-number string.
        do stuff
    except TypeError:
        # It's neither a number nor a string.
        do some other stuff

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using Mailcrypt+GnuPG <http://www.gnupg.org>

iEYEARECAAYFAkOZwtkACgkQYu1fMmOQldXEzACgqdDVvx29UBVSIfQWnGRiAAk9
xPsAn0yN5jWrUN+6SKIHdwtILRBVyQwR
=HZQq
-----END PGP SIGNATURE-----
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to