[program-l] Re: Silly Python Question

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "program-l@xxxxxxxxxxxxx" <program-l@xxxxxxxxxxxxx>
  • Date: Tue, 16 Oct 2012 14:51:48 +0000

Hi Tyler,
I just fired up the Python interpreter. When I type
dir(__builtins__)
I see the len function, or at least I assume that's what it is, but the closest 
thing I see to del is delattr. So where does del come from?

Thanks.

Jim


From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Littlefield, Tyler
Sent: Tuesday, October 16, 2012 10:25 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Silly Python Question

Because len and the others call foo.__len__. It's a quick way at getting at 
those methods without having to call them yourself, so any class can implement 
a __len__ method and len would work on it.
On 10/16/2012 7:08 AM, Homme, James wrote:
Hi,
I tend to obsess about things sometimes. I was looking at the Python Standard 
Library documentation and reading about lists, dictionaries, and files, and I 
started to wonder why len, del, and open are part of the built-in's, if that's 
the right term, rather than methods of the objects called dictionary, list, and 
file. Just saying.

Jim



________________________________

This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.




--

Take care,

Ty

http://tds-solutions.net

The aspen project: a barebones light-weight mud engine:

http://code.google.com/p/aspenmud

He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

Other related posts: