[EMAIL PROTECTED] writes: > Mike Meyer: >>Actually, I like the "len" model, which would be a new builtin that uses the >>__freeze__ method.< > Well, I presume this is a matter of personal tastes and consistency > too. This time I appreciate the freeze() too, but probably some people > can think that adding .len, .copy(), .del(), .freeze() methods to most > objects is more regular: > > len(l) l.len > copy.copy(l) l.copy() > |l| freeze(l) l.freeze() > del l l.del()
One problem is that it suggests a structure that isn't there. While other languages will have an abstract "sequence" type that has a len that, for example, iterates through the elements to count them, Python doesn't have such a thing. Adding a "len" method would require adding the method to all the types, even if only to add the default behavior. A "len" function, on the other hand, can check for __len__, and implement the default behavior if it doesn't find that (n.b. - I'm not saying that this is what "len" does; I'm just providing an example!). A freeze function could do the same thing: check for __freeze__ and use that if it exists, otherwise implement a default behavior. In Py3K you might be able to put the default behavior on object, but only if everything really inherits from object. I'm not sure the other builtin types will do that. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list