Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import sys
sys.setrecursionlimit(10000)
class Meta(type):
def __new__(*args, **kwargs):
print('I will not use metaclasses just for the fun of using them', end=' ')
magic_count = kwargs.pop('__magic_count', 0)
if magic_count > 1000:
return type.__new__(*args, **kwargs)
Meta.__new__(__magic_count=magic_count+1, *args, **kwargs)
class Foo(object, metaclass=Meta):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment