Created
October 13, 2012 08:21
-
-
Save danilobellini/3883797 to your computer and use it in GitHub Desktop.
Metaclass of a metaclass
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Created on Sat Oct 13 by Danilo de Jesus da Silva Bellini | |
# | |
# This code raises: | |
# TypeError: Can't instantiate abstract class A with abstract methods blablah | |
# However, it does not when class A inherits from "type" or "ABCMeta". | |
from abc import ABCMeta, abstractproperty | |
class A(object): | |
__metaclass__ = ABCMeta | |
def __init__(self, a_string, a_tuple, a_dict): | |
pass | |
@abstractproperty | |
def blablah(self): | |
return "blah!" | |
something = A("UnnamedClass", (ABCMeta,), {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment