re Challenge: More Compact?

Tim Hammerquist tim at vegeta.ath.cx
Mon Jul 16 22:01:42 CEST 2001


Me parece que Ben Wolfson <rumjuggler at cryptarchy.org> 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.
<wink>

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



More information about the Python-list mailing list