2013/1/16 <josef.p...@gmail.com>: > On Wed, Jan 16, 2013 at 10:43 PM, Patrick Marsh > <patrickmars...@gmail.com> wrote: >> Thanks, everyone for chiming in. Now that I know this behavior exists, I >> can explicitly prevent it in my code. However, it would be nice if a warning >> or something was generated to alert users about the inconsistency between >> var += ... and var = var + ... > > Since I also got bitten by this recently in my code, I fully agree. > I could live with an exception for lossy down casting in this case.
About exceptions: someone mentioned in another thread about casting how having exceptions can make it difficult to write code. I've thought a bit more about this issue and I tend to agree, especially on code that used to "work" (in the sense of doing something -- not necessarily what you'd want -- without complaining). Don't get me wrong, when I write code I love when a library crashes and forces me to be more explicit about what I want, thus saving me the trouble of hunting down a tricky overflow / casting bug. However, in a production environment for instance, such an unexpected crash could have much worse consequences than an incorrect output. And although you may blame the programmer for not being careful enough about types, he couldn't expect it might crash the application back when this code was written.... Long story short, +1 for warning, -1 for exception, and +1 for a config flag that allows one to change to exceptions by default, if desired. -=- Olivier _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion