re Challenge: More Compact?

Tim Hammerquist tim at
Mon Jul 16 22:01:42 CEST 2001

Me parece que Ben Wolfson <rumjuggler at> dijo:
> In that case you can eliminate a whole line this way:
> def valid_ip(ip):
>     m = re.match( r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip)
>     return (m and max(map(int, m.groups())) < 256)) or 0

You meant:
     return (m and max(map(int, m.groups())) < 256) or 0
of course?

You have a knack for one-liners. That's not necessarily a bad thing.

I am following my fish.
    -- Delirium, The Sandman

More information about the Python-list mailing list