Python动态特性
动态特性:
不需要输个数
import inspect
import dis
def howmany():
f=inspect.currentframe()
f=f.f_back
dis.disassemble(f.f_code,f.f_lasti)
n=ord(f.f_code.co_code[f.f_lasti+4])
print n
return range(n)
if __name__=='__main__':
x,y=howmany()
print x,y
>>> import inspect
>>> def howmany():
f=inspect.currentframe().f_back
return range(ord(f.f_code.co_code[f.f_lasti+4]))
>>> x,y=howmany()
>>> x
0
>>> y
1
>>> x,y,z=howmany()
>>> x
0
>>> y
1
>>> z
2
>>>
http://hi.baidu.com/mirguest/blog/item/7e21d0974a5e0c1b7bf48006.html
http://club.topsage.com/thread-252948-1-1.html