以该例子来记录自己对self和_init_的理解的理解
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------------------------------------
Function:
【整理】Python中:self和init__的含义 + 为何要有self和__init__
http://www.crifan.com/summary_the_meaning_of_self_and___init___in_python_and_why_need_them
Author: Crifan
Verison: 2012-11-27
-------------------------------------------------------------------------------
"""
class Person:
def __init__(self, newPersionName):
self.name = newPersionName;
def sayYourName(self):
print 'My name is %s'%(self.name); #My name is crifan
def initDemo():
persionInstance = Person("crifan");
persionInstance.sayYourName();
if __name__=="__main__":
initDemo();
类,有属性和方法