python decorator
1.³£Ó÷½·¨£¬²»´ø²ÎÊý
def decator(func):
def inner_func(*args):
args = (i * 2 for i in args)
return func(*args)
return inner_func
@decator
def add(a, b, c):
return a + b + c
2.´ø²ÎÊý£º
class Dec(object):
def __init__(self, i):
self.i = i
def __call__(self, func):
def inner_func(a, b, c):
return self.i * func(a, b, c)
return inner_func
@Dec(2)
def abc(x, y, z):
print "function abc"
print (x, y, z)
return x + y + z
Ïà¹ØÎĵµ£º
Posted on 18:40:00 by ÏþÔÂ and filed under Notepad++, Python
¡¡¡¡Notepad++ ÊÇÒ»¸ö¿ªÔ´µÄÎı¾±à¼Æ÷£¬¹¦ÄÜÇ¿´ó¶øÇÒʹÓ÷½±ã¡£±à¼ºÍµ÷ÊÔ Python ³ÌÐòʹÓÃʲô±à¼Æ÷»òÕß IDE ²»Í¬ÈËÓв»Í¬¼û½â¡£ÔÚ²»¿¼ÂÇʹÓõ÷ÊÔ¹¤¾ßµÄÇé¿öÏ£¬Vim »òÕß Emacs Óû§×ÔÈ»¿ÉÒÔÎÞÊÓÆäËû±à¼Æ÷£¬²»¹ýÔÚ Windows »·¾³Ï£¬Ê¹Óà Notepad++ Ö ......
typeÏà¹Ø£º
ËùÓÐ×Ô¶¨ÒåÀàA
ÆäʵÀý£¬Èç a = A()
ʹÓÃtypeÔËËã·û·µ»ØµÄ¶¼ÊÇ<type, 'instance'>
¶ø»ù±¾ÀàÐÍ
±ÈÈç b = 3
type(b)£¬½á¹ûÊÇ<type, 'int'>
pythonµÄtype²»ÏñC++ÖеÄtypeidÄÇÑù£¬¿ÉÒÔÏÔʾÀàÃû¡£
£¨×¢£º¶ÔÓÚûÓÐvirtualº¯ÊýµÄÀà¶øÑÔ£¬typeidÊDZàÒëʱÆÚµÄÊÂÇ飨Ҳ¾ÍÊǾ²Ì¬ÀàÐÍ£©£»¶ÔÓÚÓÐvirtualº¯ ......
ÕæÊǵ¹Ã¹£¬¸ÕÂò²»¾ÃµÄÒÆ¶¯Ó²ÅÌ£¬×òÌìɾ³ýÒ»¸ö·ÖÇøÊ§°Üºó£¬¼¸¸ö·ÖÇø¶¼²»¼ûÁË£¬ÄÃÈ¥ÐÞ£¬Î´¹û
»»Á˸öÐµģ¬µ«ÆäÖÐÊý¾ÝȫûÁË¡£ÄÇÊÇÎÒÆ½Ê±ÊÕ¼¯µÄºÜÓÐÓõÄ×ÊÁÏ
ºÜ¶à¶¼¿ÉÒÔÖØÐÂÏÂÔØ£¬µ«ÔõÄÜÏëÆðÓ²ÅÌÖеÄËùÓж«Î÷
½ñÌì»»Ó²ÅÌ»ØÀ´
¾ÍÏñдһ¸ö±£´æÖ¸¶¨Â·¾¶ÏÂËùÓÐÎļþ¼ÐºÍÎļþÃûµÄ³ÌÐò
ÕâÑù£¬Èç¹û¶«Î÷¶ªÁË£¬¿´¿´ÄÇÀïÓÐЩʲô£¬Ò² ......
multiprocessing — Process-based “threading” interface
Introduction
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Glo ......