In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to better write Python programs, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
In the middle are some settings about unittest. The * section sets the compiler of the python file to pyunit.
PY file, we can type in VIM command mode: make enter to perform the test of the entire module, if you like to use Gvim, you can also click the make shortcut button on the toolbar to do this. The third set the make operation of the file named test*.py to execute only the test file, so that when writing a specific test program, we don't have to run all the test code every time.
In the above settings, writing a few lines of the Python program ensures that when I write a new file, Vim will automatically select a template file for me based on the file name, so I have less code to type. You can download the complete one I use.
The vimrc file, along with the template files used in the previous configuration: skeleton.py, test.py, and alltests.py. If you need to, you can replace them with the pathname of Windows, such as this:
Autocmd FileType python setlocal makeprg=\ "C:\\ Program\ Files\\ Plone 2\\ Python\\ python\"\. / alltests.py autocmd BufNewFile,BufRead test*.py setlocal makeprg=\ "C:\\ Program\ Files\\ Plone 2\\ Python\\ python\"\%
It is important to note that any spaces that appear here should be escaped with a backslash in front of them; other special characters should also be escaped accordingly, such as the Windows-style path separator\, and double quotes "(if the file name and path to be used in Windows contain spaces, be sure to wrap them in double quotes).
Note: I have found that there is something wrong with the command line of writing Python program operation calls in Vim 6.1. it can not capture all the output of the program, and the output of our PyUnit will also be affected by this bug. It is recommended to use the * * version of Vim. For example, the current 6.3has revised the bug.
[BOTTOM] [TOP] Code completion in addition, I also used [WWW] pydiction, which is a pretty good autocomplete script for Python code. To use this feature, I put it in the ~ / .vim/tools directory and added the following settings in .vimrc:
"python auto-complete code" Typing the following (in insert mode): "os.lis" will expand to: "os.listdir (" Python auto-completion function, just press Ctrl-N repeatedly. Is it helpful for you to read the above content after reading if has ("autocmd") autocmd FileType python set complete+=k~/.vim/tools/pydiction endif? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.