1

So, I was following this tutorial on Youtube. This person is running python commands from the shell.

-TLDR;

He has a function called nfe(args1, args2...) in a notes.py file in some directory.

However, he is able to call the kalles-Mackbook-Pro:~ kalle$ nfe args... from his shell (on his mac)

How?

1 Answer 1

3

You can place an executable nfe on your PATH with the following content:

#!/bin/usr/python

import sys
sys.path.insert(0, '/path/to/notes/')

from notes import nfe

sys.exit(nfe(*sys.args[1:]))

This process can be automated by creating a package and registering console-script entry points:

setup(
    ...,
    entry_points={
        'console_scripts': [
            'nfe = my_package.notes:nfe',
        ]
    }
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.