Oct-23-2021, 09:17 PM
(Oct-23-2021, 04:44 PM)ChrisOfBristol Wrote: The answer was to type info pythonThen the point of making a package is somewhat gone if do it like this.
This gives the syntax as python3 -m mymodules.myapp datafile.dat
So before talk about Entry Points to make if for command line,
if want to load file in a package there is
importlib.resources
(New in Python 3.7)So eg in Packaging Python Projects if i add this.
from importlib import resources def add_one(number): return number + 1 with resources.open_text('example_package', 'somefile.dat') as fp: # Just 42 in somefile.dat number = fp.read()Then can now use number from the package.
>>> from example_package import example >>> >>> example.add_one(2) 3 >>> example.add_one(int(example.number)) 43 >>>