找了一下,原來是 python 特有的 decorator 功能。
這一篇 的說明,配合循序漸進的 example code,可以清楚說明這個 @ 符號的功能。
因為沒辦法簡短的說明,所以...
以
@deco_function def myfunc(): ..經過@deco_function 之後,myfunc( ) 已經不是 myfunc( ) 了....
這一篇 也一樣...循序漸進...
這一篇 是中文的...
(Pdb) help
Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt
a c continue exit l q s until
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where
Miscellaneous help topics:
==========================
exec pdb
Undocumented commands:
======================
retval rv
import os
for rootpath, dirlist, filelist in os.walk("./"):
print rootpath, dirlist, filelist
.
|-- 2
| |-- 3
| | |-- 4a
| | `-- 4b
| `-- 3a
|-- 2a
`-- 2b
`-- X
./ ['2b', '2'] ['2a']
./2b [] ['X']
./2 ['3'] ['3a']
./2/3 [] ['4b', '4a']
import os
for rootdir,dirlist,filelist in os.walk('./'):
print rootdir, dirlist, filelist
if '2b' in dirlist:
dirlist.remove('2b')
./ ['2b', '2'] ['2a']./2b [] ['X']
./2/3 [] ['4b', '4a']
./2 ['3'] ['3a']
./ ['2b', '2'] ['2a']
./2b [] ['X']
./2/3 [] ['4b', '4a']
./2 ['3'] ['3a']
./ ['2b', '2'] ['2a']
import xml.dom.minidom
xmlroot = xml.dom.monodom.parse('./.repo/manifest.xml')
for node in xml.childnodes:
if node.Name == 'project':
print node.getAttribute('path')
File "xml.py", line 1, in <module>
from xml.dom.minidom import parse, parseString
File "/home/charles-chang/test/python/xml.py", line 1, in <module>
from xml.dom.minidom import parse, parseString
ImportError: No module named dom.minidom
import subprocess
args = ['ls']
proc = subprocess.Popen(args)
proc.wait()
print "done"
"""exec" python -E "$0" "$@"""