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 9267439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:33:00+00:00 2026-06-18T14:33:00+00:00

from time import ctime import inspect class MetaC(type): def __init__(cls,name,bases,attrd): print isinstance(cls,MetaC) print inspect.isclass(cls)

  • 0
from time import ctime
import inspect

class  MetaC(type):
  def  __init__(cls,name,bases,attrd):
    print   isinstance(cls,MetaC) 
    print   inspect.isclass(cls)
    super(MetaC,cls).__init__(name,bases,attrd)
    print "careated %s" %ctime()

class  Foo(object):
  __metaclass__=MetaC
  def  __init__(self):
    print "i am here "

I get this output:

True  
True  
careated Fri Feb  8 12:33:32 2013  

The argument(cls) in MetaC class __init__ method,

Is cls a class or an instance?

  • 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-18T14:33:01+00:00Added an answer on June 18, 2026 at 2:33 pm

    cls is both a class and an instance. A class is merely an instance of a meta class.

    >>> class MetaC(type):
    ...   def  __init__(cls, name, bases, attrs):
    ...     print 'cls: ', cls
    ...     print 'cls is instance of MetaC: ', isinstance(cls, MetaC)
    ... 
    >>> class C(object):
    ...   __metaclass__ = MetaC
    ... 
    cls: <class '__main__.C'>
    cls is instance of MetaC: True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works as expected def outer_func(): from time import * print time() outer_func() I
Lets say I have a function: from time import sleep def doSomethingThatTakesALongTime(number): print number
my python code like this: #!/usr/bin/env python import threading from time import sleep,ctime loops=[4,2]
I'm using the following to get utc datetime: import datetime import time from pytz
From time to time I see something like this: class Clazz { private int
at the start and end of my program, I have from time import strftime
import os import sys, urllib2, urllib import re import time from threading import Thread
Is there any significant difference between: from time import time start = time() #
Here is a program that I wrote in Python: import sys from time import
I have the following code which is executed from the command line: import cgi,time,os,json,sys,zipfile,urllib2

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.