#! /usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2017/6/30 16:54
# @Author  : xiongyaokun
# @Site    : 
# @File    : test02.py
# @Software: PyCharm

class Person:
    '''Represents a person'''
    population = 0

    def __init__(self, name):
        '''Initializes the person's data'''
        self.name = name
        print '(Initializing %s)' % self.name

        # When this person is created, he/she
        # adds to the population
        Person.population += 1

    def __del__(self):
        '''I am dying.'''
        print '%s says bye.' % self.name
        Person.population -= 1

        if Person.population == 0:
            print 'I am the last one.'
        else:
            print "There are still %d people left." % Person.population

    def sayHi(self):
        '''Greeting by the person. Really. That's all it does.'''
        print "Hi, my name is %s." % self.name

    def howMany(self):
        '''Prints the current population.'''
        if Person.population == 1:
            print "I am the only person here."
        else:
            print "We have %d persons here." % Person.population

swaroop = Person('Swaroop')
swaroop.sayHi()
swaroop.howMany()

jack = Person('jack')
jack.sayHi()
jack.howMany()


# swaroop.__del__()


kalam = Person('Abdul Kalam')
kalam.sayHi()
kalam.howMany()

# 访问类的文档字符串
print Person.__doc__
# 访问方法的文档字符串
print Person.sayHi.__doc__