[PYTHON] Tools used for sutra copying

I am trying to copy sutras to understand the code of others. If that doesn't work, you'll need to compare it to the original code, and then I'm using the following tools:

Reindent

A tool to realign Python indentation. It is very difficult to compare if the indentation standard of the reference source code or the code you wrote is different, so we use this to unify. pip install Rindent introduces the "rindent" command. To execute, just specify the file to be formatted as an argument. Makes a backup of the original file by default. Indent formatting is unified to PEP8 with 4 spaces. There seems to be a tool called autopep8 that modifies to PEP8 including non-indentation.

Python3 not supported

Reindent didn't work in python3.

$ reindent
Traceback (most recent call last):
  File "/opt/3gpu/bin/reindent", line 2, in <module>
    from reindent import main
  File "/opt/3gpu/lib/python3.4/site-packages/reindent.py", line 71
    except getopt.error, msg:

Overall, the exception notation is Python2. It would be nice to replace the comma with as in this regard, but all other prints are calls without parentheses.

gvimdiff

I use gvimdiff for comparison. There are some other tools such as meld, but as a result of trying some, I am using this one. There will also be personal tastes here. The default for gvimdiff is nowrap, so long lines will not wrap. Simply writing set nowrap in .vimrc didn't work. Since there was a method to enable wrap only when (g) vimdiff is started on StackOverflow, I have adopted it.

autocmd FilterWritePre * if &diff | setlocal wrap< | endif

jedi (+ emacs, auto-complete)

I'm using jedi for code completion. When combined with emacs auto-complete, it is easy to complete long variables, function names, etc. in the source of the sutra-copying source that was read earlier.

If there are other useful tools, I will add them.

Recommended Posts

Tools used for sutra copying
Refactoring tools for Python
What is Python? What is it used for?
Frequently used Linux commands (for beginners)