re Challenge: More Compact?
John Machin
machin_john_888 at hotmail.com
Sun Jul 15 22:46:03 EDT 2001
Alex <new_name at mit.edu> wrote in message news:<etdhewe0y3q.fsf at quiche-lorraine.mit.edu>...
> def ip_p(ip_string):
>
> try: bytes = map(int, ip_string.split('.'))
> except ValueError: return None
> return 0 <= min(bytes) <= max(bytes) < 256
>
This doesn't check (a) that there are exactly four doodads (b) that
the doodads are composed of 1 to 3 digits. It will say that "0" and
"-0000000.0.9.8.7.+6.0000005" are valid IP addresses.
More information about the Python-list
mailing list