On 25 September 2012 11:51, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> On 25/09/2012 11:38, Oscar Benjamin wrote: > >> On 25 September 2012 08:27, Mark Lawrence <breamore...@yahoo.co.uk> >> wrote: >> >> On 25/09/2012 03:32, Mark Adam wrote: >>> >>> On Mon, Sep 24, 2012 at 5:55 PM, Oscar Benjamin >>>> <oscar.j.benja...@gmail.com> wrote: >>>> >>>> try: >>>>> f.pos = 256 >>>>> except IOError: >>>>> print('Unseekable file') >>>>> >>>> >>>> >>>> Something along these lines http://docs.python.org/dev/** >>> whatsnew/3.3.html#pep-3151-****reworking-the-os-and-io-**** >>> exception-hierarchy<http://**docs.python.org/dev/whatsnew/** >>> 3.3.html#pep-3151-reworking-**the-os-and-io-exception-**hierarchy<http://docs.python.org/dev/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy> >>> >? >>> >> >> >> I just tried to find out what error would be raised by seeking on a file >> that doesn't support seeking and II think it's just OSError in the >> reworked >> hierarchy. The error in Python 2.7 is >> >> Traceback (most recent call last): >> File "tmp.py", line 2, in <module> >> sys.stdin.seek(5) >> IOError: [Errno 29] Illegal seek >> >> This corresponds to ESPIPE from errno.h which isn't referred to anywhere >> in >> pip 3151: >> http://www.python.org/dev/**peps/pep-3151/<http://www.python.org/dev/peps/pep-3151/> >> >> So I guess it would still need to be >> >> try: >> f.pos = 256 >> except OSError as e: >> if e.errno != 29: >> raise >> print('Unseekable file') >> >> Oscar >> >> >> >> > The thing I was thinking of is actually in the thread "syntax to continue > into the next subsequent except block" over on Python ideas. This? try: f.pos = 256 except OSError as e if e.errno == 29: print('Unseekable file') Oscar
-- http://mail.python.org/mailman/listinfo/python-list