1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
cola
  • 12,198
  • 36
  • 105
  • 165

3 Answers3

5

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
Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
2

.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.

Wooble
  • 87,717
  • 12
  • 108
  • 131
  • python -B abc.py , still get the .pyc files there. – cola Dec 19 '11 at 14:06
  • Did you delete the existing ones before running it? What version of Python are you using? (Also keep in mind that you probably really don't want to stop them from being created; this will slow down your script's startup time with no advantages whatsoever.) – Wooble Dec 19 '11 at 16:04
1

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

yosukesabai
  • 6,184
  • 4
  • 30
  • 42