Specs: Python 2.7
I\'m working on a project that has several modules, I want to activate some features from the __future__ module in all of them. I would like to import
Another approach would be using isort. isort
has a -a
command line flag to add imports to files that you specify. Simply running isort
without arguments will run it recursively on all python files in the current working directory and all subdirectories.
If, like me, you have a virtual environment inside that folder, and are using git (or have an equivalent way of listing only your files) and don't want to run it on all files inside that virtual environment, you can use something like:
git ls-tree -r HEAD --name-only | grep "\.py$" | xargs isort -a -y "from __future__ import division"