Fredrik Lundh wrote: > "Bryan" wrote: > >>> and how do you make sure that everything subclasses this base class ? >> in this hypothetical case, i was assuming len() would be put in object and >> every >> class subclasses object implicitly or explicitly (ie, new style classes >> only). >> if it was done that way, would len(obj) == obj.len() in all cases? > > why should *everything* be forced to have a length ? > > </F> >
good point. you're right, everything should not have to be forced to have a length. i thought ruby did something like putting length functionality in their highest level base class. then subclasses would either inherit it or could modify it in their own class. my coworker who knows ruby complains about python's len(obj) too. so i assumed ruby implements this in their equivalent base object class. i just briefly searched the ruby docs, but i can't seem to find it. if it is done this way in ruby, then i wonder what happens what obj.length would return for objects that you would not normally associate as having a length, such as what steve holden mentioned 1.length. bryan -- http://mail.python.org/mailman/listinfo/python-list