python file API

Mark Adam dreamingforward at gmail.com
Mon Sep 24 22:32:42 EDT 2012


On Mon, Sep 24, 2012 at 5:55 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com> wrote:
> 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')

Well it might be that the coupling between the python interpreter and
the operating system should be more direct and there should be a
special exception class that bypasses the normal overhead in the
CPython implementation so that error can be caught in the code without
breaking syntax.  But I don't think I'm ready to argue that point....

markj



More information about the Python-list mailing list