Simple pychecker question
Neal Norwitz
neal at metaslash.com
Sun Jun 9 10:48:21 EDT 2002
On Sun, 09 Jun 2002 03:04:09 -0400, 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. For example, with your code
>> above, calling f(f=2) would be better written f(2). However for
>> Tkinter, named args can be useful when there are a bunch of parameters
>> and you only want to use the last.
>
> For a routine named and structured like this:
>
> def transmit(data, timeout=1.0):
>
> which of the following would you say was the better call in some code
> that might be remote from that definition above?
>
> 1. transmit('this is a string', 5)
>
> 2. 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:
timeout = 5
transmit('this is a string', timeout)
There really doesn't seem to be a right way, it just depends.
Neal
More information about the Python-list
mailing list