Fredrik Lundh <fredrik at pythonware.com> wrote: > George Sakkis wrote: > > > 1) why having a "generic operation" len() that ends up looking for an > > ugly special *method* called __len__() makes sense, while calling > > directly a method len() doesn't > > for the very reason Mike explained: keeping implementation interfaces > separate from public interfaces has allowed Python to avoid a certain > category of design fragmentation that other languages suffer from.
Fredrik, I am not arguing for the argument's sake, I just don't get it: Python requires my class to define __len__, otherwise len() fails. Why not require len() as a method instead and forget about __len__ ? Does len() (the function) do anything smarter behind the scenes than just passing the ball to __len__ ? That could justify its role but AFAIK it doesn't. George _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com