Skip to content

Instantly share code, notes, and snippets.

@danilobellini
Created October 13, 2012 08:21
Show Gist options
  • Save danilobellini/3883797 to your computer and use it in GitHub Desktop.
Save danilobellini/3883797 to your computer and use it in GitHub Desktop.
Metaclass of a metaclass
#!/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