Created
December 11, 2015 00:50
-
-
Save freakboy3742/6fdfc127a0c46d0040f4 to your computer and use it in GitHub Desktop.
Py3 Metaclasses for fun and profit
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
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