> 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 |