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

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
主站蜘蛛池模板: 罗江县| 弥勒县| 晋宁县| 瑞金市| 睢宁县| 乐平市| 惠东县| 垣曲县| 房山区| 东港市| 恩平市| 静宁县| 祁门县| 邛崃市| 个旧市| 元朗区| 多伦县| 长丰县| 邢台县| 文安县| 阿坝| 萝北县| 沁水县| 临猗县| 怀远县| 宝清县| 南昌县| 临桂县| 宝应县| 大英县| 双城市| 牟定县| 南投市| 耿马| 永州市| 乐至县| 黑水县| 龙岩市| 吉林省| 精河县| 类乌齐县|