1
對於Bash完成腳本,我需要從已安裝的Python模塊中獲取與模式匹配的所有變量。我只想使用Python感知功能,以避免解析註釋等。在Bash中獲取Python模塊變量列表
對於Bash完成腳本,我需要從已安裝的Python模塊中獲取與模式匹配的所有變量。我只想使用Python感知功能,以避免解析註釋等。在Bash中獲取Python模塊變量列表
如果需要,您可以使用python -c
來執行單行Python腳本。例如:
bash$ python -c "import os; print dir(os)"
如果你想通過一個模式來過濾,你可以這樣做:
bash$ python -c "import os; print [x for x in dir(os) if x.startswith('r')]"
['read', 'readlink', 'remove', 'removedirs', 'rename', 'renames', 'rmdir']
謝謝你,這僅僅是事情!由此產生的代碼:'python -c「import invenio.config; print dir(invenio.config)」| tr -s「','」「\ n」| grep^CFG_' – l0b0 2010-05-17 17:43:41