Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a Python package with one command line [closed]

Tags:

python

I'm a newbie in Python. And I don't know how to run a python package with only one command line. I have been searched it on GG but I have no key-word. There is my folder:

├── config.json
└── my_source
    ├──__init__.py
    ├──filter.py
    └──get_new_users.py

And config.json contains 3 parameters and able change by the user. So, I want to run this my_source package with one command line like this:

my_source -c config.json

Could I able to run my code in this way? If it's possible. Could anyone give me a key-word or a way to do it? If you need more info, please leave a comment. Thank you.

like image 326
Han Van Pham Avatar asked Nov 28 '22 00:11

Han Van Pham


1 Answers

To run a python module/package specify the -m flag.

For example in your situation it will be something like:

python -m my_course.filter

See this SO question for more info.

like image 99
Kunal Mukherjee Avatar answered Dec 09 '22 09:12

Kunal Mukherjee