What value should be passed to make a function use the default argument value?

Fredrik Lundh fredrik at pythonware.com
Fri Oct 6 06:42:08 EDT 2006


Antoon Pardon wrote:

> IMO this is a very natural thought process for a python programmer.
> So a python programmer seeing the first will tend to expect that
> last call to work.

on the other hand, if a Python programmer *writes* some code instead; 
say, a trivial function like:

	def calculate(a, b):
             # approximate; gonna have to fix this later
             return a + b * 1.2

chances are that he did *not* intend this to be called as

         calculate(a=1, b=2)

or, for that matter,

         calculate(b=2, a=1)

or

         calculate(1, b=2)

just because the Python calling machinery currently happens to allow 
that.  And chances are that he did *not* expect to be stuck with those 
argument names for the foreseeable future, just because someone else 
decided to interpret things in the most literal way they possibly could.

Python 2.X doesn't provide convenient support for distinguishing between 
accidental and intentional argument names when you implement a function; 
that's a wart, not a feature, and it may be addressed in 3.X.

</F>




More information about the Python-list mailing list