re Challenge: More Compact?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Jul 16 03:09:14 EDT 2001


Sun, 15 Jul 2001 21:36:22 -0400, Tim Peters <tim.one at home.com> pisze:

> def valid_ip(ip):
>     m = re.match(r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip)
>     if m:
>         elements = map(int, m.groups())
>         return max(elements) < 256
>     return 0

Is 0127.0.0.00001 a valid IP?

If yes, then it should be accepted. If no, what about 127.0.0.001?

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list