thanks!! your ipcheck is perfect fo me!!


2006/2/3, Fredrik Lundh <[EMAIL PROTECTED]>:
Sbaush wrote:

> My app has in input an ip address in IPv4 notation.
> is there a function that control if input is a string in IPv4 notation?

here's one way to do it:

def ipcheck(s):
    try:
        a, b, c, d = [chr(int(c)) for c in s.split(".")]
    except ValueError:
        return False
    else:
        return True

another way is to use regular expressions; see

     http://www.regular-expressions.info/examples.html

</F>



--
http://mail.python.org/mailman/listinfo/python-list



--
Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to