Using Python from Cocoa App via PyObjc - numbers dont match...

sapsi saptarshi.guha at gmail.com
Wed Nov 8 20:22:58 EST 2006


Hi,
I managed to create a python class and instantiate that from my
Objective C Cocoa App (its not a python app).
Essentially, i made two classes in IB and then another class(ogle) with
outlets for these two.

Now here is the implementation for ogle.m
-(void)awakeFromNib
{
    NSNumber *n=[NSNumber numberWithFloat:40.4];
    NSLog(@"%@",n);

    NSNumber *b=[it2 printNok:n];
    NSLog(@"%@",b);

    //
}
The first output in the console is 40.4 and the second
-40.40000152587891.

If i change the NSLog(s)  to "%f",[n floatValue] (and the second
likewise) the first is 40.400002 and the second is -40.400002.

Why does this happen?
Thanks
Saptarshi

p.s the python routine printNok, just returns the negative of the
number i.e printNok:

def printNok_(self, obj):
        return -obj




More information about the Python-list mailing list