-
-
Save adeak/03bb1802f17e27017fbae2d6d44dad6d to your computer and use it in GitHub Desktop.
if x or y vs x or y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate(): | |
class SketchyBool: | |
counter = 0 | |
def __init__(self): | |
self.boolcounts = [] | |
def __bool__(self): | |
self.boolcounts.append(SketchyBool.counter) | |
SketchyBool.counter += 1 | |
return True | |
def __str__(self): | |
return str(self.boolcounts) | |
return SketchyBool(), SketchyBool() | |
x,y = generate() | |
z = x or y | |
if z: | |
pass | |
print(x, y) # [0, 1] [] | |
x,y = generate() | |
if x or y: | |
pass | |
print(x, y) # [0] [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment