Re: Proposal: === and !=== operators

2014-07-10 Thread Alex Burke
On 9 July 2014 09:00, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__

Re: error handling when opening files

2014-07-09 Thread Alex Burke
> Interestingly, did you know that even *closing* a file can fail? No I didn't, interesting piece on information for sure! I thought close() is usually made to always succeed regardless if it actually hosed up. Any idea what the context manager will do in that case? (I ask as that else-with form l

Re: error handling when opening files

2014-07-09 Thread Alex Burke
> If that's what you're expecting, then your message is wrong, because > you say "file never opened" - but you possibly DID open it, and maybe > read something from it. The choice between the two forms should be > based on whether you want to distinguish between errors on opening and > errors on re

error handling when opening files

2014-07-07 Thread Alex Burke
Hi there, While reading up on a previous thread 'open() and EOFError' I saw the following (with minor changes to help make my question clearer) block suggested as a canonical way to open files and do something: try: f = open(path) except IOError: handle_error() else: with f: d