Search notes:

Python import system: Using the -m command line option

The command line option -m runs a module as a script. If the module is a package (that is essentially a directory), it runs (or tries to run) __main__.py.
This is demonstrated with the following simple example: A directory, named minusM, contains three files:
Their content is one print() statement only: __init__.py:
print('minusM: __init__.py')
Github repository about-Python, path: /import-system/minusM/__init__.py
__main__.py:
print('minusM: __main__.py')
Github repository about-Python, path: /import-system/minusM/__main__.py
__mod__.py:
print('minusM.mod')
Github repository about-Python, path: /import-system/minusM/mod.py
If the Python interpreter is started in the directory that contains minusM like so:
python -m minusM
the following is printed:
minusM: __init__.py
minusM: __main__.py
If the interpreter is started like so:
python -m minusM.mod
this is printed:
minusM: __init__.py
minusM.mod

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1738303911, '18.225.92.25', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/import-system/minus-m(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78