Go to file
Fierelier 55dee42376 Add comments 2023-04-03 19:04:17 +02:00
module Change "Running " to "Running new instance of ", to make how modules work more obvious 2023-04-03 19:03:57 +02:00
.gitignore Initial commit 2022-12-19 08:01:04 +01:00
LICENSE Initial commit 2022-12-19 08:01:04 +01:00
example.py Add comments 2023-04-03 19:04:17 +02:00
readme.txt Add mfpl.g 2022-12-19 10:43:21 +01:00

readme.txt

This is the script most of my future (2022.12.19+) Python projects will be based off of. Some of it is inspired by Lua.

Compatible with Python 3.4 and up. Lower may work.

The initialization works like this:
1. bootstrap(globName,modName) is ran -- It initializes the mfp module, which contains all extra functionality. It takes 2 arguments, the name the module will be in global, and the name of the module. Preferably, you do not edit this.
2. init() is ran -- This where you write you initialization code, if your script is usable as a module.
3. main() is ran, if your script is not an import -- This is where you put your program code, if it is one.

Provides the following mfpl.* (local to current script):
* s: The script's full path.
* sd: The script's full directory.
* g: The script's global as a Bunch.

Provides the following mfp.* (global to all scripts):
* s: The main script's full path.
* sd: The main script's full directory.
* p(pathList): Combines a list into a path string.
* pUp(path): Goes up (..) in the path.
* setProgramName(name): Set the name of your main program, only works on first call. You should run it before running any other mfp modules.
* programName: The name of your program. DO NOT modify this variable directly, use mfp.setProgramName().
* require(name): Runs a module from mfp.paths, saves its global, and returns the script's global as a Bunch. If a module of the same name has already been required, it returns the already saved global.
* dorequire(name): Does the same as above, but does not save the globals, and can re-require.
* paths: The directories mfp should search for modules in with mfp.require(). ? in all paths is replaced with the name given to mfp.require().
* dofile(path): Runs a script from a raw path. It does not use mfp.paths. Returns the script's global as a Bunch.
* docode(text): Runs string as Python code. Returns the script's global as a Bunch.
* g: A Bunch where you can store variables accessible by all mfp modules and scripts.
* Bunch(): Creates a Bunch. Read about it here: https://github.com/Infinidat/munch
* bunchify(list): Converts a list into a Bunch.
* unbunchify(Bunch): Converts a Bunch into a regular list.