printing class __dict__

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • piyush.subscription@gmail.com

    printing class __dict__

    hi,
    i am a newbie. so bear wth me
    i wrote a program like this
    --
    class H(object):
    def __init__( self):
    self.data =10
    def e ( self ):
    pass
    def f ( self ):
    pass

    class H1(H):
    x2 = 11
    def __init__(self):
    self.x = 10

    class details(object) :
    def data(self,class Name):
    print classname.__dic t__
    print classname.__nam e__
    print classname.__bas es__

    bc = details()
    bc.data(H1)

    when i run it, i get error like this
    NameError: global name 'classname' is not defined

    can't i pass 'class' like an 'object'?

    any suggestions to access other classes details inside a class?
  • Diez B. Roggisch

    #2
    Re: printing class __dict__

    piyush.subscrip tion@gmail.com wrote:
    hi,
    i am a newbie. so bear wth me
    i wrote a program like this
    --
    class H(object):
    def __init__( self):
    self.data =10
    def e ( self ):
    pass
    def f ( self ):
    pass
    >
    class H1(H):
    x2 = 11
    def __init__(self):
    self.x = 10
    >
    class details(object) :
    def data(self,class Name):
    print classname.__dic t__
    print classname.__nam e__
    print classname.__bas es__
    >
    bc = details()
    bc.data(H1)
    >
    when i run it, i get error like this
    NameError: global name 'classname' is not defined
    >
    can't i pass 'class' like an 'object'?
    >
    any suggestions to access other classes details inside a class?
    Python is case-sensitive. Now analyze your code.

    Diez

    Comment

    Working...