A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/076571.html below:

[Python-Dev] functions vs methods (was Re: trunc())

[Python-Dev] functions vs methods (was Re: trunc()) [Python-Dev] functions vs methods (was Re: trunc())Aahz aahz at pythoncraft.com
Sun Jan 27 21:53:09 CET 2008
On Sun, Jan 27, 2008, "Martin v. L?wis" wrote:
>
> Students just asked me why len() is not a method, and I didn't know a
> good answer; the same holds for many other builtins. This is a clear
> candidate for a method, IMO.

This is why len() is not a method:

    map(len, list_of_strings)

What I don't know is to what extent this argument still holds in the
presence of listcomps and genexps:

    [s.len() for s in list_of_strings]

However, you still need ``len`` as a function to pass around as a
callback in other cases where you need a generic function because the
type of your data is not predetermined.

In any event, I consider dropping len() from builtins to be gratuitous
breakage, even in 3.0.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of     
indirection."  --Butler Lampson
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4