What is not objects in Python?

Terry Reedy tjreedy at udel.edu
Sun Sep 28 21:17:19 CEST 2008

process wrote:
> I have heard some criticism about Python, that it is not fully object-
> oriented.

Feel free to ignore it if you wish.

> What is not an object in Python?

Depends on what you mean by 'in'.  Python is a language for defining and 
manipulating information objects.  Code 'in' Python is not usually a 
maniputed object, though is can be (by eval, exec, and compile, for 
instance).  Names in code that are only used to directly access objects 
typically are also, typically, not objects themselves.

> Why isn't len implemented as a str.len and list.len method instead of
> a len(list) function?

Partly history and partly practicality.  Len is implemented as .__len__ 
;-).  The len function is one, __len__ methods are many.  If you want to 
pass an argument to a function, passing len is easier that passing 
operator.attrgetter('__len__').  Passing '__len__' (or 'len') would be 
easy, but using len is easier than using getattr(ob,'__len__').


More information about the Python-list mailing list