#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# static_method.py
#
# Copyright 2013 xx <xx@ubuntu>
#
class foo():
def __init__(self):
print 'this is init'

@staticmethod #声明静态方法
def bar():
print 'this is foo.bar()'

def decorator1(func):
def wrap1():
print 'this is wrap 1 begin'
func()
print 'this is wrap 1 end'
return wrap1

def decorator2(func):
def wrap1():
print 'this is wrap 2 begin'
func()
print 'this is wrap 2 end'
return wrap1

# python装饰方法,类似java aop
# <=> decorator2(decorator1(fun1))
@decorator2
@decorator1
def fun1():
print 'this is fun1()'


def main():
foo.bar() #类调用
print '*' * 20
foo().bar() #对象调用
print '*' * 20
fun1()

return 0

if __name__ == '__main__':
main()