[Python-ideas] Allow filter(items)

Terry Reedy tjreedy at udel.edu
Wed Aug 7 19:31:40 CEST 2013


On 8/7/2013 6:01 AM, Alexander Belopolsky wrote:

>  From Guido's time machine comes a pronouncement:
  <http://bugs.python.org/issue2186#msg63026>.

As Raymond points out in a later message, it is standard in Python for 
None passed to a function to mean 'no argument, do something that does 
not require an value for this parameter'. It does not mean 'use a value 
of None for this parameter and do with None whatever would be done with 
any other value'.

Usually, only trailing parameters are allowed to be given None and then 
it is given in the definition as a default.
   def f(a, b=None, c=None): pass
can be called f(x), f(x, y), f(x, y, z), and f(x, None, z) or f(x, c=z). 
Because of the last option, there is never a need for the user to 
explicitly pass None.

What is unusual about filter is not the use of None to mean 'no 
argument, behave differently', but the need for it to be written 
explicitly by the caller to get the null behavior.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list