[aklug] Re: Lists

From: Tim Johnson <tim@akwebsoft.com>
Date: Tue Jul 26 2011 - 07:26:29 AKDT

* Christopher Howard <christopher.howard@frigidcode.com> [110725 20:57]:
> Question for the Perl programmers and the Python programmers: in either
> language, can you re-implement the length function for lists? (Without
> actually using the built-in length function, of course.)

  python has builtin functions and `len()' is one.

  python has something called `special methods' and `__len()__ is
  one.

  Therefore you can define a class with a __len__() method,
  instantiate an object from the class, and execute the method
  by calling len() with the instance as an argument.

-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Tue Jul 26 07:26:31 2011

This archive was generated by hypermail 2.1.8 : Tue Jul 26 2011 - 07:26:32 AKDT