On 24 September 2012 23:41, Mark Adam <[email protected]> wrote:
> > seek() and tell() can raise exceptions on some files. Exposing pos as an
> > attribute and allowing it to be manipulated with attribute access gives
> the
> > impression that it is always meaningful to do so.
>
> It's a good point, python already is allowing exceptions to be caught
> within "properties", so exceptions from such an attribute could
> presumably be handled similarly.
>
There are many situations where a little bit of attribute access magic is a
good thing. However, operations that involve the underlying OS and that are
prone to raising exceptions even in bug free code should not be performed
implicitly like this. I find the following a little cryptic:
try:
f.pos = 256
except IOError:
print('Unseekable file')
Oscar
--
http://mail.python.org/mailman/listinfo/python-list