I've isolated my problem to this short script below:
Code: Select all
init python:
from functools import partial
class Book(object):
def __init__(self, reqs=[]):
self.reqs = reqs
def canUse(self):
if checkReqs(self.reqs):
return True
return False
def checkReqs(reqs):
for _req in reqs:
if not _req():
return False
return True
def isTrue(bool):
if bool is True:
return True
return False
default allowreading = False
default mybook = Book(reqs=[partial(isTrue, allowreading)])
label start:
$ _tmp = mybook.canUse()
"Can I read the book? -> [_tmp]" # Returns 'False' (and that is correct!)
$ allowreading = True
$ _tmp = mybook.canUse()
"Can I read the book? -> [_tmp]" # Returns 'False' (But... why? Shouldn't the partial-function evaluate to 'True' now?)
$ mybook.reqs=[partial(isTrue, allowreading)] # lets try updating the book.reqs value with exactly the same as I initialised it
$ _tmp = mybook.canUse()
"Can I read the book? -> [_tmp]" # Returns 'True' (why does this work? I've supplied exactly the same partial-function like before)
return
But, it does return True after I've supplied exactly the same reqs.... please help, I'm going nuts.