overriding bool() for custom class
Question or problem about Python programming: All I want is for bool(myInstance) to return False (and for myInstance to evaluate to False when in a conditional like if/or/and. I know how to override >, >> bool(MinPriorityQueue([]) False >>> bool(MinPriorityQueue([1,3,2]) True Solution 4: test.__nonzero__() Solution 5: Similar to John La Rooy, I use: class Test(object): def […]
Continue Reading