Any loose file sitting on your current path is a python module:
python3 -m my_module
This has limitations. No ability to split your thoughts out and organize anything.
Directories can be modules too.
python3 -m another_module
__init__.py
and __main__.py
are special:
__init__.py
runs when your module is imported the first time__main__.py
runs when your module is invoked as main (withpython3 -m
)
Just dig around. Invoking the module will use the hard-coded values in the function:
python3 -m representative_example
__main__.py
doesnt' have to be your only entrypoint. Here, I've provided two more that allow user input in different ways:
# Prints help
python3 -m representative_example.cli --help
# Yells at you
python3 -m representative_example.cli
# Uses a default
python3 -m representative_example.cli -d1 22
# Prints help
python3 -m representative_example.cli -d1 22 -d2 1.2
Or let it read a file:
python3 -m representative_example.file_io --json_file ./example_data.json
first generate the example mat file:
python3 -m weee.gen_example
run like this:
python3 -m weee --mat_file ./testo.mat