0

I'm trying to understand how type works, specifically the three-argument form. How would this look?

Here's my shot, but this is a TypeError.

def type_(name, bases, dict_):
    base = next(base for base in bases if hasattr(base, '__new__'))
    return super(type(base)).__new__(type(base))

type('A', (int, object,), {}) # __main__.A
type_('A', (int, object,), {})

TypeError: super.__new__(type): type is not a subtype of super
Hatshepsut
  • 5,962
  • 8
  • 44
  • 80

0 Answers0