Python TensorFlow automatic complement must be reproduced

Source: Internet
Author: User
Tags readline

Recently in the study deeplearning, the theory looked over, ready to start using TensorFlow to do development. Of course, we need to use Python now. Accustomed to automatically fill the full function, or want to be in Python can be automatically filled, read a lot of posts, http://blog.csdn.net/robertsong2004/article/details/48165557, indeed can automatically fill up.

But found that after each run of Python, exit () out of the Python environment, the discovery will not go to Python, hehe, carefully look at the discovery, history's command to add to the startup file, it is not very egg pain, You can't always clean the exit () history, so go inside and find out, Historyfile = Os.path.join (os.environ[' home '], '. Pythonstartup '), This sentence to add History command to the end of the file, the problem is here, so, the file changed to OK, history file to create a separate history file, under the Vim. Pythonhistory, then change the original statement to:

History_file = Os.path.join (os.environ["Home", ". Pythonhistory"), the rest is the same, so it's OK. Finally, the original post becomes:

# python startup file import readline import rlcompleter import atexit import os #tab completion Readline.pars       E_and_bind (' tab:complete ') #history file Historyfile = os.path.join (os.environ[' home ', '. Pythonhistory ') Try:   Readline.read_history_file (historyfile) except:pass atexit.register (readline.write_history_file,historyfile) Del Os,historyfile,readline,rlcompleter, record the detailed process below:


1. CD ~

2. Vim. Pythonstartup

Copy the above code into the file, save the exit (: Wq)

3. Vim. Pythonhistory

New History file: Continue Save exit (: Wq)

4. Vim. BASHRC

At its end add: Export pythonstartup= "/home/xxxx/.pythonstartup" (best absolute path, xxxx corresponding to your username)

5. Source. BASHRC

Source. bashrc file is ok.


The automatic complement effect is still possible, but it is still a bit of an imperfect place.

For example, want to automatically fill TensorFlow, this function is still not possible. It's very convenient to use Ipython,

In addition, we often FTP to the server development, in the shell to edit the Python file, or without vim to edit the file, at this time, we also need to edit the file when it is necessary to automatically fill, and then need a dictionary, you can refer to Http://www.jb51.net /article/58009.htm This, I tested can be applied, but there is no tensorflow in the dictionary, you need to add, I will slowly solve the problem later.


工欲善其事 its prerequisite, the environment this piece first came here, the back slowly record. Of course, hope to find some like-minded to learn tensorflow together.


2017-5-2 continued:

Vim Install TensorFlow Support

In fact, only one command is required:

Python pydiction.py TensorFlow
However, be sure to position the current folder to the location of the pydiction.py file: ~/.vim/pydiction

Then you will find that a new dictionary file is generated, look up the tensorflow, and find that you have joined a lot of


Another place to pay attention to. The dictionary path inside the VIMRC is under the Tools folder, where only the newly generated dictionary files need to be covered and completed under the Tools folder. (CP command, find out how to apply yourself)

Test the effect:

Does it feel great?

Here's a little trick, after you import as, because there is no TF keyword in the dictionary, I am here to copy all the TensorFlow commands to the end of the file, and then replace the TensorFlow with the TF batch. Note Do not replace globally, replace with CTRL + V mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.