corelp.Section module
- class corelp.Section(*, path: Path | str = None, new: bool = False, num: int = 0, parent_path: Path | str = None)[source]
Bases:
objectThis class defines decorator instances allowing to create section functions. Cache results into a folder, if another call occurs, can load-back the precalculated data.
- Parameters:
Examples
>>> from corelp import Section ... >>> section = Section(path=export_path) ... >>> @section() ... def add(a, b=0) : ... testfunc.print('Hello World') ... return a + b ... >>> testfunc.print('3+0=', add(3)) # First call calculates and save result >>> testfunc.print('3+0=', add(3, 0)) # Second call loads back precalculated results >>> testfunc.print('1+3=', add(1, 3)) # New call with other parameters : crushed previous results with new ones >>> testfunc.print('1+3=', add(1, b=3)) # Second call with these parameters : loads precalculated results ... >>> @section(cache=False) # Creates an index of 2, does no caching ... def sub(a, b=0) : ... return a - b ... >>> @section(num=10) # Creates an index of 10 ... def mul(a, b=0) : ... return a * b ... >>> @section(new=True) # Creates an index of 11, always creates new cache ... def div(a, b) : ... return a / b
- new: bool
- num: int
- parent_path: Path | str
- path: Path | str
- property subfolder