cola
cola

Reputation: 12466

How can I remove backup files, I don't need backup files

The original file name is view.py, forms.py but python automatically adds/saves some file named view.pyc, forms.pyc

I want to delete those extra view.pyc and forms.pyc files.

Why do I get those .pyc files?

Or how can I tell python not to create those extra files with .pyc extension?

Upvotes: 1

Views: 593

Answers (3)

sehe
sehe

Reputation: 393134

pyc files are compiled bytecode files, not backup files

  • 6.1.2 ``Compiled'' Python files http://docs.python.org/release/1.5.1p1/tut/node43.html

    As an important speed-up of the start-up time for short programs that use a lot of standard modules, if a file called "spam.pyc" exists in the directory where "spam.py" is found, this is assumed to contain an already-``byte-compiled'' version of the module spam. The modification time of the version of "spam.py" used to create "spam.pyc" is recorded in "spam.pyc", and the file is ignored if these don't match.

Update:

To avoid writing pyc files (Python 2.6+)

  • start with the -B flag (python -B)
  • set the PYTHONDONTWRITEBYTECODE environment variable.

See also How to avoid .pyc files?


Vim backups are named view.py~

Disable vim backups using

:se nobackup

Upvotes: 5

Wooble
Wooble

Reputation: 89927

.pyc files are compiled python modules created by the python interpreter; they have nothing at all to do with vim.

You can avoid them by invoking python with the -B flag or by setting the PYTHONDONTWRITEBYTECODE environment variable.

Upvotes: 2

yosukesabai
yosukesabai

Reputation: 6244

it's not vim, python compiles your py into that format to make things go faster.

Upvotes: 1

Related Questions