Skip to content

Instantly share code, notes, and snippets.

@jasonbot
Created February 11, 2020 21:58
Show Gist options
  • Save jasonbot/68d7188d5d03692a040c55c65792d63b to your computer and use it in GitHub Desktop.
Save jasonbot/68d7188d5d03692a040c55c65792d63b to your computer and use it in GitHub Desktop.
import random
class TemperamentalClass(type):
@classmethod
def __instancecheck__(cls, other):
return random.choice([True, False])
class MyClass(metaclass=TemperamentalClass):
pass
for x in range(5):
print(isinstance(None, MyClass))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment