官术网_书友最值得收藏!

Deleting Python-compiled files

When you run your project for the first time, Python compiles all your *.py code in bytecode-compiled files, *.pyc, which are used later for execution.

Normally, when you change the *.py files, *.pyc is recompiled; however, sometimes when switching branches or moving the directories, you need to clean up the compiled files manually.

Getting ready

Use your favorite editor and edit or create a .bash_profile file in your home directory.

How to do it…

Add this alias at the end of .bash_profile, as follows:

# ~/.bash_profile
alias delpyc="find . -name \"*.pyc\" -delete"

Now, to clean the Python-compiled files, go to your project directory and type the following command in the command line:

$ delpyc

How it works…

At first, we create a Unix alias that searches for the *.pyc files and deletes them in the current directory and its children. The .bash_profile file is executed when you start a new session in the command-line tool.

See also

  • The Setting the Subversion ignore property recipe
  • The Creating the Git ignore file recipe
主站蜘蛛池模板: 莱阳市| 敦化市| 西藏| 微博| 伽师县| 天峻县| 盐亭县| 昌邑市| 蕉岭县| 左云县| 钟祥市| 安多县| 永靖县| 襄垣县| 高邑县| 新密市| 巴中市| 井陉县| 本溪市| 沿河| 闵行区| 新余市| 平和县| 鄱阳县| 宁波市| 鲁山县| 抚远县| 瓦房店市| 吕梁市| 灌云县| 汶上县| 上杭县| 永嘉县| 营山县| 水富县| 铅山县| 嘉峪关市| 大田县| 富裕县| 深水埗区| 钦州市|