Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Seekable files Date: Tue, 15 Mar 2016 13:16:37 +0200 Organization: A noiseless patient Spider Lines: 23 Message-ID: <87a8m0dm96.fsf@elektro.pacujo.net> References: <56e7e57a$0$1589$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="27715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pVlGacSVpYMhNAwYwP7Il" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:b+AAj2rF+ohkayUGzCCrY/X5AhI= sha1:g2UraM6ooL/jAuYyoAOCyUTfzpg= Xref: csiph.com comp.lang.python:104934 Jon Ribbens : > I'd just do something like: > > try: > fileobj.seek(where-i-want-to-seek-to) > except (AttributeError, EnvironmentError): > # file is not seekable Unlike Java, Python does not declare syntactically which exceptions the caller should expect. Unfortunately, the library documentation is not clear on it, either. So it is often a bit difficult to write proper try-except logic around a function. Having to specify the possible exceptions in Java is very painful and has complicated the introduction of closures to Java quite a bit. I think it points to a big practical problem in the whole exception paradigm. Makes you wonder if the old error code mechanism would have been better, after all. ("Why does Go not have exceptions?" .) Marko