Supply condition in function call

Rustom Mody rustompmody at gmail.com
Fri Mar 27 09:48:35 EDT 2015


On Friday, March 27, 2015 at 10:05:21 AM UTC+5:30, Steven D'Aprano wrote:
> On Fri, 27 Mar 2015 01:21 pm, Rustom Mody wrote:
> 
> > Anyway my point is that in python (after 2.2??) saying something is an
> > object is a bit of a tautology -- ie verbiage without information.
> 
> 
> Er, it's *always* been a tautology. Every value in Python is an object,
> including classes, and that has been always the case.
> 
> However, just because it's a tautology doesn't mean it isn't useful to know.
> (Tautologies are also known as *facts* and knowing facts is usually a good
> thing.) For the majority of programming languages, it is not the case that
> all values are objects, and not all people reading the documentation should
> be expected to know that this applies to Python.

I am making a point of pedagogy not semantics.
This is help(filter) for python 2 and 3.

Python2:
Help on built-in function filter in module __builtin__:

filter(...)
    filter(function or None, sequence) -> list, tuple, or string
    
    Return those items of sequence for which function(item) is true.  If
    function is None, return the items that are true.  If sequence is a tuple
    or string, return the same type, else return a list.
--------------------------

Python 3
Help on class filter in module builtins:

class filter(object)
 |  filter(function or None, iterable) --> filter object
 |  
 |  Return an iterator yielding those items of iterable for which function(item)
 |  is true. If function is None, return the items that are true.
 |  
 |  Methods defined here:
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __iter__(self, /)
 |      Implement iter(self).
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  __next__(self, /)
 |      Implement next(self).
 |  
 |  __reduce__(...)
 |      Return state information for pickling.
------------------------

Try and put yourself in the place of a noob:

Knows some C, not much else.
Starts studying python.
Good until a point.
Then suddenly hit... map, filter, and the worst of all lambda.
More he reads less he understands.
Tries help... Gets the above.

So which do you think helps him more python 2 or 3?



More information about the Python-list mailing list