[Python-3000-checkins] r58914 - in python/branches/py3k: Lib/io.py Lib/test/test_io.py Modules/_fileio.c
Christian Heimes
lists at cheimes.de
Fri Nov 9 02:05:38 CET 2007
Guido van Rossum wrote:
> Actually, requiring isinstance(pos, int) is too rigid. You should use
> __index__() instead, which allows other int-like numbers but not float
> numbers.
I wasn't familiar with the __index__() method.
Is this fine with you?
def seek(self, pos, whence=0):
if not hasattr(pos, "__index__"):
raise TypeError("an integer is required")
pos = pos.__index__()
if whence == 0:
...
I want it to raise a TypeError to keep it consistent with _fileio's seek.
Christian
More information about the Python-3000-checkins
mailing list