Simple pychecker question

Peter Hansen peter at engcorp.com
Sun Jun 9 11:24:48 EDT 2002


Neal Norwitz wrote:
> 
> Peter Hansen wrote:
> > Neal Norwitz wrote:
> >> I personally think that superfluous use of named args are bad, but that
> >> the feature is good when used properly.  
> >
> > transmit('this is a string', timeout=5)
> >
> > My point: named arguments can increase readability and maintainability.
> > That's not superfluous, to me.
> 
> I agree that they can enhance readability.  With the example above,
> it's questionable, but that's my opinion.  Suppose the function was
> transmitWithTimeout()?  Or suppose the code looked like this:

transmitWithTimeout() would imply it always had a timeout.
(In my example it did, with the default of 1.0, but I could as
well have had timeout=0.0 for the default.)

>         timeout = 5
>         transmit('this is a string', timeout)

This would be just fine.  Quite readable, although the name
'timeout' is duplicated unnecessarily.  With the named argument,
the intention is clear but there is no need for duplication.

> There really doesn't seem to be a right way, it just depends.

Exactly, which was my point.  Why give a warning for one of two
perfectly acceptable alternatives?

-Peter



More information about the Python-list mailing list