Skip to content

Instantly share code, notes, and snippets.

@adeak
Last active July 4, 2020 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeak/03bb1802f17e27017fbae2d6d44dad6d to your computer and use it in GitHub Desktop.
Save adeak/03bb1802f17e27017fbae2d6d44dad6d to your computer and use it in GitHub Desktop.
if x or y vs x or y
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