Musings about Python syntax

Jim Althoff jima at aspectdv.com
Tue Oct 19 15:27:59 EDT 1999


At 07:03 PM 10/19/99 +0200, Fredrik Lundh wrote:
>steve_allison at my-deja.com wrote:
>> i) if Python is as object orientated as is claimed, why are things like
>> len() not member functions of list/tuples ?
>
>hey, what makes you think len(obj) is less object-
>oriented than obj.len() ?  it's just syntax, you know.
>

But it IS less consistent syntax with not much advantage
("del" is a different story).  So it would be very nice if
I could write aList.len() if I prefer that to len(aList).


>and except from a few builtin types, len actually
>*is* a method, spelled __len__.  the len() function
>is just there for your convenience...
>    
>also see:
>http://www.python.org/doc/FAQ.html#6.5
>
>> ii) similarly, why is 'del' operator like, and not a member function of
>> those types that support it ?  having an 'append' method, but a 'del'
>> operator seems peculiar.
>
>"del" doesn't destroy an object, it removes
>the name from the local namespace.
>
>also see:
>http://www.python.org/doc/FAQ.html#4.17
>http://www.python.org/doc/FAQ.html#6.14
>
></F>
>
><!-- (the eff-bot guide to) the standard python library:
>http://www.pythonware.com/people/fredrik/librarybook.htm
>-->
>
>
>-- 
>http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list