Sure; or perhaps better

try:
  pos = pos.__index__()
except AttributeError as err:
  raise TypeError("an integer is required") from err

On Nov 8, 2007 5:05 PM, Christian Heimes <[EMAIL PROTECTED]> wrote:
> 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
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to