I was running test_bool.py from python 2.5 against
jythonx and ran into this unappealing error:
b = a()
if b: print b
The problem in this case is the PyObjectDerived looks
for __nonzero__, if it finds it, it is executed. Then
the returned value has __nonzero__ called on it. In
this case, the code ends up in a recursive nightmare.
Im going follow the advice of a jythonxer to let this
sit for awhile since the initial solution/reaction
does not look pretty or minor. Hopefully something
simple will suggest itself.
I think the question somewhat hinges on when
__nonzero__ is called. As we can see calling user
defined method is fine but put it in a situation where
the call is directly against the __nonzero__ method,
things go haywire. If its isolated to a few
situations where a boolean return value will suffice,
it may end up being cheap.
This also raises the question of how many equivilent
methods exist, methods that are not __nonzero__ but
calculate return values based off of something
returned from a user defined method. An entirely new
may be needed to deal with the "general" problem.
anyway, it doesn't look pleasant,
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.