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/2001-August/017322.html below:

[Python-Dev] copy, len and the like as 'object' methods?

[Python-Dev] copy, len and the like as 'object' methods?Tim Peters tim.one@home.com
Mon, 27 Aug 2001 16:00:36 -0400
[Tim, giving his "<wink>" key a rest]
> Say what?!  What kind of stupid-ass language spells the len() function as
> if it were a method?  That's carrying consistency to an irrational
> extreme --

[James_Althoff@i2.com]
> Well, only those stupid-ass, irrational, and extremist languages that
> include classes and methods as an integral and uniform part of
> the language from the very beginning, I guess.

I was more than half joking, but not entirely.

> The "stupid-ass, irrational, extremist" side is merely saying that
>
> mylist.append(x)
> mylist.length()
> mylist.extend(y)
> mylist.length()
>
> is more sensible (easier for new-to-python programmers to discover,
> more consistent, more mainstream)

Of course that's what they're saying, although "mainstream" is debatable:
pure-OO languages aren't exactly mainstream, and Python isn't a pure-OO
language.  It doesn't follow that Python is mainstream, but neither does it
follow that ".length()" isn't an eyesore <wink>.

> But you all clearly like spelling it len(mylist) and it's already
> there, so
> ... whatever.

I wouldn't want to write math.pi.sin() either -- functional notation for
pure (referentially transparent; side-effect free) functions has a long and
fine tradition, in and out of computer languages, and I *think* "get the
length of some list", not "list, of all the things I may ask you for, in
this case I want your length".  It simply reads better to me as a function.

Guido said he'd do it the other way had he to do it over, so I'll have to
rest on "it's already there".




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