Visit here or see the follwoing usage guide.
-
Open terminal
-
Run
pip install pycodestyle
- then run
pip install --upgrade autopep8
-
cd(navigate) to the directory where your python file does exist(suppose your file name is encdec.py).
-
Run the follwowing command to format the encdec.py to conform to the PEP 8 style guide.
autopep8 --in-place --aggressive --aggressive encdec.py
-
Modify or corrode the code formatting(like increasing the spacing between operands and operator etc.)
-
Rerun the autopep8 command
You will see your code formatted.
MacBook-Pro:mobmsg admin$ pip install pycodestyle
Collecting pycodestyle
Downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kB)
100% |████████████████████████████████| 51kB 273kB/s
Installing collected packages: pycodestyle
Successfully installed pycodestyle-2.3.1
MacBook-Pro:mobmsg admin$ pip install --upgrade autopep8
Collecting autopep8
Downloading autopep8-1.3.2-py2.py3-none-any.whl (42kB)
100% |████████████████████████████████| 51kB 288kB/s
Requirement already up-to-date: pycodestyle>=2.3 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from autopep8)
Installing collected packages: autopep8
Successfully installed autopep8-1.3.2
MacBook-Pro:mobmsg admin$ ls
LICENSE mobmsg setup.py
README.md sample_output.md
MacBook-Pro:mobmsg admin$ cd mobmsg/
MacBook-Pro:mobmsg admin$ ls
__init__.py __init__.pyc encdec.py encdec.pyc
MacBook-Pro:mobmsg admin$ autopep8 --in-place --aggressive --aggressive encdec.py
MacBook-Pro:mobmsg admin$ autopep8 --in-place --aggressive --aggressive encdec.py
MacBook-Pro:mobmsg admin$