Several lines of code to call functions in the unix pipeline style, and several lines of unix

Source: Internet
Author: User
Tags python decorator

Several lines of code to call functions in the unix pipeline style, and several lines of unix
After using linux, you basically know its pipeline, which is to use the output of a program or command as the input of another program or command.

To put it bluntly, let's look at how python can be used to call functions in the unix pipeline style.

#coding=utf-8class Pipe:    def __init__(self, func):        self.func = func    def __ror__(self, other):        return self.func(other)@Pipedef add(args):    return sum(args)@Pipedef incr(arg):    return arg + 1print [1, 2, 3] | add | incr
The principle is that the decorator + operator is overloaded. (For more information about the decorator, see <the essence of the python decorator>)
Here, the magic method _ ror _ overload operator |
It's really simple and rude. My life is short. I use python!




How to view the function interfaces called by executable files in Unix/Linux

There is no good tool to achieve the effect you have mentioned. The strings command can be seen, but you have to analyze it carefully. The usage is as follows:
Strings program name | more
Or input the result to a file, such:
Strings program name> input file name
Then vi enters the file name to see the corresponding content.

In unix, I used vi to edit the c file. How can I quickly jump to the declaration of the referenced function?

You should press Esc to enter the command mode, and then enter "? "And"/"keys can both enter the baseline mode.
Add a string to it to search.
/Find and match the string function. The system will automatically find and highlight all the words found in the "/string" command mode.
String, and then go to the first string. If you want to continue searching, you can press the "F" key. Press the "N" key to continue searching;
? You can also use "? String "searches for a specific string. It is similar to"/string ", but it is a forward query string.

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.