3

I would like to create a new type using type(...). How do I provide the Meta class for this type?

1 Answer 1

4

You don't provide it to type as an argument, the metaclass would subclass type itself, so you would call the metaclass' constructor instead.

Sign up to request clarification or add additional context in comments.

2 Comments

I am not sure I understand. Could you provide a code example for assigning a Meta with abstract = True or a link which explains this?
Are you talking about Django here? Those aren't true metaclasses. If what you want is a Django-style Meta class on a model, just create a class object with whatever class attributes you need, then add that class to the attributes dictionary you pass to type with the key Meta.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.