PyWart: os.path needs immediate attention!
robert.kern at gmail.com
Sun Jul 31 05:31:22 CEST 2011
On 7/29/11 8:50 PM, Steven D'Aprano wrote:
> Andrew Berg wrote:
>>>>>> os.path.exists(path, ignoreSymLnks=False)
>> I actually agree with you on these, which I suppose is interesting.
> Guido has a rule of thumb: "No constant arguments". Or another way to put
> it: if a function takes an argument which is nearly always a constant
> (usually, but not always, a flag) then it is usually better off as two
That's not quite right (although I can never find a direct quote from Guido
whenever I need to dissect the niceties of the rule). The rule of thumb is more
like: "No literal arguments." That is, if you are typically going to use True
and False literals for a flag, it's better to have two functions. However, if
you have a suite of interoperating functions with the same flag argument, and
one might reasonably want to pass the same flag value to several different calls
using a variable, that's a reasonable use.
> But having said that, I'm currently writing a library where nearly all the
> functions violate the No Constant Argument rule. (The API isn't yet stable,
> so I may still change my mind.) Make of that what you will.
I suspect this may be an instance of the latter case.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list