Benjamin Peterson <[EMAIL PROTECTED]> added the comment: This is because y is a new-style class (because file is) and z is not. If the return type of new-style classe's len is not an int, Python tries to convert it, which is why that works for the first example. However, that conversion doesn't happen in old-style classes. Try:
>>> class z(object): ... def __init__(self, name): ... self.f = file(name, 'r') ... def __len__(self): ... self.f.seek(0, 2) ... return self.f.tell() >>> x = z('/tmp/longfile') >>> len(x) [Whatever it is] ---------- nosy: +benjamin.peterson resolution: -> invalid status: open -> closed __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2612> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com