pyclean
Remove Python bytecode files
SYNOPSIS
pyclean [options] [directory]
PARAMETERS
-v
Verbose mode: print the names of files as they are removed.
-d
Remove empty directories after removing bytecode files.
-e
Exclude files or directories matching the specified pattern. This option can be used multiple times for multiple patterns.
-i
Interactive mode: prompt the user for confirmation before removing each file.
-j
Use multiple processes to speed up the cleanup.
Requires the 'multiprocessing' module.
-h, --help
Show help message and exit.
[directory]
The directory to clean. Defaults to the current directory.
DESCRIPTION
The pyclean command is a utility that removes .pyc
and .pyo
files (Python bytecode files) from a directory tree. These files are generated when Python source code is executed and contain compiled bytecode, speeding up subsequent executions. However, they can sometimes cause issues, especially after code updates or when moving code between different Python versions. pyclean helps in ensuring that the latest version of your Python code is being used by removing these potentially outdated bytecode files. By default, pyclean operates recursively on the current directory. It's a simple, effective tool for managing Python project dependencies and maintaining code integrity. It is generally used to make sure that old compiled files don't interfere with new code after project changes or environment adjustments.
CAVEATS
pyclean primarily targets .pyc
and .pyo
files. It doesn't handle other types of generated files or dependencies. Be cautious when using the -d
option, as it might remove directories that are intentionally kept empty. Always test after using pyclean, especially with complex projects, to ensure no unintended consequences.
EXIT STATUS
The pyclean command returns 0 on success and a non-zero value on failure.
SEE ALSO
find(1)