Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8135317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:23:09+00:00 2026-06-06T10:23:09+00:00

I was reading this interesting post on metaclasses What is a metaclass in Python?

  • 0

I was reading this interesting post on metaclasses What is a metaclass in Python?. The accepted answer shows how to create a class using type with the following signature.

type(name of the class,
tuple of the parent class (for inheritance, can be empty),
dictionary containing attributes names and values)

I tried to create ‘type’ class using the above signature and I was surprised that I was allowed to create one in the first place! Your views are appreciated!

type = type('type',(),{});

Second, after I created a type class using the above syntax, I was not able to do

myclass = type('myclass',(),{}); 

and
type = type('type',(),{});

I got an error saying

Traceback (most recent call last): File “”, line 1, in
TypeError: object.new() takes no parameters

But, when I tried to the following, I could succeed.

class myclass(object):
    pass

I am puzzled coz, according to my understanding the above snippet should invoke type in an attempt to create the class ‘myclass’. So whats going on!? Am I missing some detail?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:23:10+00:00Added an answer on June 6, 2026 at 10:23 am

    You’ve shadowed type with type with type = type('type',(),{})

    Note that semi-colons are redundant in Python.

    So you’re creating a type that can’t do anything.

    That’s why the later type breaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading through this interesting post about using JavaScript to generate an image
i have been reading this interesting article which is increasing my every growing confusion
While reading this class BitmapFactory I noticed that almost all methods inside are static.
After reading this article I don't have a clear answer: http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/ Will browsers interpret
After reading this post I kinda felt in the same position as the guy
I was reading this interesting article regarding the display of the memory parameters in
I've been wondering about this for a while after reading through an interesting article
I'm reading through a jquery plugin, and find this interesting syntax: 'sth'+ +new Date
After reading this post and some derivative publications (ddotdash.com) I wonder whether it is
Well I was reading this post and then I came across a code which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.