Skip to content

Instantly share code, notes, and snippets.

@freakboy3742
Created December 11, 2015 00:50
Show Gist options
  • Save freakboy3742/6fdfc127a0c46d0040f4 to your computer and use it in GitHub Desktop.
Save freakboy3742/6fdfc127a0c46d0040f4 to your computer and use it in GitHub Desktop.
Py3 Metaclasses for fun and profit
class JavaClass:
# Details go here
pass
class JavaInterface:
# Details go here
pass
class JavaType(type):
# some magic here...
class MyObject(metaclass=JavaType, extends=JavaClass, implements=JavaInterface):
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return "MyObject instance %s, %s" % (self.x, self.y)
obj = MyObject(37, 42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment