[Numpy-discussion] Casting Bug or a "Feature"?
Thu Jan 17 06:27:44 CST 2013
On Thu, Jan 17, 2013 at 2:34 AM, Matthieu Brucher
> Actually, this behavior is already present in other languages, so I'm -1 on
> additional verbosity.
> Of course a += b is not the same as a = a + b. The first one modifies the
> object a, the second one creates a new object and puts it inside a. The
> behavior IS consistent.
The inplace operation is standard, but my guess is that the silent
downcasting is not.
>>> a = 1
>>> a += 5.3
>>> a = 1
>>> a *= 1j
I have no idea about other languages.
> 2013/1/17 Paul Anton Letnes <firstname.lastname@example.org>
>> On 17.01.2013 04:43, Patrick Marsh 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 + ...
>> > Patrick
>> I agree wholeheartedly. I actually, for a long time, used to believe
>> that python would translate
>> a += b
>> a = a + b
>> and was bitten several times by this bug. A warning (which can be
>> silenced if you desperately want to) would be really nice, imho.
>> Keep up the good work,
>> NumPy-Discussion mailing list
> Information System Engineer, Ph.D.
> Blog: http://matt.eifelle.com
> LinkedIn: http://www.linkedin.com/in/matthieubrucher
> Music band: http://liliejay.com/
> NumPy-Discussion mailing list
More information about the NumPy-Discussion