Re: Returned BOOL values from Objc to Python
Wool Sweater Soft <[email protected]> Fri, 25 Oct 2013 10:26:52 -0700
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
> isVisible = myviewcontroller.isVisible() > if isVisible is False: > # do something special The problem is that you shouldn't use if x is False: to test falsehood. Nor, according to PEP 8, should you use if x == False: Instead, use if not x: Python's is operator compares object identity, not value. Your test will fail for any "false-y" value that's not the False singleton itself, like None or an empty list. > it seems to return an int (1 or 0) In case you're not aware of it, ObjC's BOOL is not a true boolean type; it's just a typedef'd signed char, so the integer 0 or 1 you get is strictly correct. There's actually no way for PyObjC to know that it should be a turned into a Python boolean, unless you create bridge metadata for your method. -- Josh Caswell ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ Pyobjc-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev