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
functions.

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.

--
Robert Kern

"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

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to