In [1]:
class Student(object):
    pass

In [2]:
class Student2(object):
    pass

In [6]:
class Student(object):
    def __init__(self,):
        pass
    def test(self,):
        print self
        
s1 = Student()
s1.test()


<__main__.Student object at 0x1065fdd90>

In [7]:
type(str)


Out[7]:
type

In [9]:
class A:
    def __init__(self,name):
        self.name = name
    def test(self,):
        return self.name

In [10]:
def test():
    pass

In [15]:
a = A('a1')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-278a1d1d48f4> in <module>()
----> 1 a = A('a1')

<ipython-input-9-6930a79985be> in __init__(slef, name)
      1 class A:
      2     def __init__(slef,name):
----> 3         self.name = name
      4     def test(self,):
      5         return self.name

NameError: global name 'self' is not defined

In [16]:
test.__get__()


Out[16]:
<function __main__.test>

In [17]:
dir(1)


Out[17]:
['__abs__',
 '__add__',
 '__and__',
 '__class__',
 '__cmp__',
 '__coerce__',
 '__delattr__',
 '__div__',
 '__divmod__',
 '__doc__',
 '__float__',
 '__floordiv__',
 '__format__',
 '__getattribute__',
 '__getnewargs__',
 '__hash__',
 '__hex__',
 '__index__',
 '__init__',
 '__int__',
 '__invert__',
 '__long__',
 '__lshift__',
 '__mod__',
 '__mul__',
 '__neg__',
 '__new__',
 '__nonzero__',
 '__oct__',
 '__or__',
 '__pos__',
 '__pow__',
 '__radd__',
 '__rand__',
 '__rdiv__',
 '__rdivmod__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__rfloordiv__',
 '__rlshift__',
 '__rmod__',
 '__rmul__',
 '__ror__',
 '__rpow__',
 '__rrshift__',
 '__rshift__',
 '__rsub__',
 '__rtruediv__',
 '__rxor__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__sub__',
 '__subclasshook__',
 '__truediv__',
 '__trunc__',
 '__xor__',
 'bit_length',
 'conjugate',
 'denominator',
 'imag',
 'numerator',
 'real']

In [18]:
class X:
    def __init__(self,):
        self.name ="xyz"

In [19]:
x  = X()

In [20]:
dir(x)


Out[20]:
['__doc__', '__init__', '__module__', 'name']

In [21]:
getattr(x,'name')


Out[21]:
'xyz'

In [23]:
getattr(x,'name2','unknown')


Out[23]:
'unknown'

In [24]:
hasattr(x, 'name2')


Out[24]:
False

In [ ]:


In [ ]: