printing class __dict__

Diez B. Roggisch deets at nospam.web.de
Mon May 19 10:01:37 EDT 2008


piyush.subscription at 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,className):
>         print classname.__dict__
>         print classname.__name__
>         print classname.__bases__
> 
> 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



More information about the Python-list mailing list