[Pyobjc-dev] Comparing int and floats fails?
Brought to you by:
ronaldoussoren
From: Francesco P. <fpi...@no...> - 2003-12-15 02:48:36
|
Hi everybody! I stumbled into a very weird behaviour and I do not know if it is a Python bug, an PyObjC bug, one of my bugs or any combination of the three. So, I implement a mouseMoved_ function in a subclass of NSImageView in a Python script. In this function I have a comparison between the pixel value of the displayed image and two thresholds: if (v >= z2): self.pixelField.setStringValue_ ('>= ' + str (z2)) return if (v <= z1): self.pixelField.setStringValue_ ('<= ' + str (z1)) return else: self.pixelField.setFloatValue_ (v) return for some weird reason, if all of v, z1 and z2 are floats, everything works as expected. If v is a int while z1 and z2 are floats, the second statement gets ALWAYS executed. I should add that z in an element of a Python array of unsigned ints. Has anybody ever seen something like this? Cheers Francesco --- Francesco Pierfederici <fpi...@no...> NOAO/AURA Inc. http://www.noao.edu/staff/fpierfed/ 950 N. Cherry Ave. Phone: +1 520 318 8402 Tucson, AZ 85719 USA FAX: +1 520 318 8360 |