Netstat Speed
Jorgen Grahn
grahn+nntp at snipabacken.dyndns.org
Wed Sep 6 08:48:02 EDT 2006
On Sat, 2 Sep 2006 20:13:01 +0200, Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> wrote:
> Jorgen Grahn enlightened us with:
>>| def ip_is_active(addr):
>>| """Return success if 'addr' shows up in the output from 'netstat -an'.
>>| We assume that a suitable version of netstat exists.
>>| """
>
> If I have an "if" in the docstring, I always write the "else" case as
> well:
>
> """Returns True if 'addr' shows up in the output from 'netstat -an',
> and False otherwise. We assume that a suitable version of netstat
> exists.
> """
>
> This makes it clear what happens in either case.
Tastes differ. I think it's clear enough without the "else". Note that I
changed the name of the function too, to make it read like a test (or rather
an assertion): "if not ip_is_active('127.0.0.1')".
/Jorgen
--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn!
More information about the Python-list
mailing list