<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="http://192.168.180.206:8001/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://192.168.180.206:8001/feed.php">
        <title>wiki.niziak.spox.org - programming:python</title>
        <description></description>
        <link>http://192.168.180.206:8001/</link>
        <image rdf:resource="http://192.168.180.206:8001/_media/wiki:dokuwiki.svg" />
       <dc:date>2026-05-13T13:04:39+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:daemon?rev=1704123573&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:hate?rev=1744630088&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:install?rev=1685513122&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:logging?rev=1707553309&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:modules?rev=1708715711&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:multiple_versions?rev=1687427196&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:oop?rev=1704278068&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:packaging?rev=1743529986&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:pip?rev=1744293869&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:pipx?rev=1760457974&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:run_system_command?rev=1708674371&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:socket?rev=1703769785&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:sys?rev=1704127935&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:tinyrpc?rev=1704131341&amp;do=diff"/>
                <rdf:li rdf:resource="http://192.168.180.206:8001/programming:python:venv?rev=1722525181&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://192.168.180.206:8001/_media/wiki:dokuwiki.svg">
        <title>wiki.niziak.spox.org</title>
        <link>http://192.168.180.206:8001/</link>
        <url>http://192.168.180.206:8001/_media/wiki:dokuwiki.svg</url>
    </image>
    <item rdf:about="http://192.168.180.206:8001/programming:python:daemon?rev=1704123573&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-01-01T15:39:33+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>daemon</title>
        <link>http://192.168.180.206:8001/programming:python:daemon?rev=1704123573&amp;do=diff</link>
        <description>daemon

systemd

Python daemon and systemd service

When using systemd, it is no need to implement daemon in main process.
Systemd simply works with foreground services (default service type=simple. See Type=).

Hints:

	*  To force systemd to wait for full process startup, use sd_notify(3) and set unit</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:hate?rev=1744630088&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-04-14T11:28:08+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Why I hate Python</title>
        <link>http://192.168.180.206:8001/programming:python:hate?rev=1744630088&amp;do=diff</link>
        <description>Why I hate Python

	*  Using pyserial to read real time data from sensor cause 100% CPU usage
#216
	*  &lt;https://github.com/openwisp/ansible-openwisp2/issues/494&gt;
	*  “parallel pip install”: 
cat requirements.txt | xargs --max-args=1 --max-procs=&quot;$(nproc)&quot; pip3 install</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:install?rev=1685513122&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-31T06:05:22+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Install</title>
        <link>http://192.168.180.206:8001/programming:python:install?rev=1685513122&amp;do=diff</link>
        <description>Install

apt-get install python3

python3 as python

sudo apt install python-is-python3</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:logging?rev=1707553309&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-10T08:21:49+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>logging</title>
        <link>http://192.168.180.206:8001/programming:python:logging?rev=1707553309&amp;do=diff</link>
        <description>logging

prevent multiple log handlers

More: &lt;https://stackoverflow.com/a/60042406/2042400&gt;


if not (self.log.handlers):
    self.logr.addHandler(journalHandler)</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:modules?rev=1708715711&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-23T19:15:11+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>modules</title>
        <link>http://192.168.180.206:8001/programming:python:modules?rev=1708715711&amp;do=diff</link>
        <description>modules

5.2.1. Regular packages

Python defines two types of packages, regular packages and namespace packages. Regular packages are traditional packages as they existed in Python 3.2 and earlier. A regular package is typically implemented as a directory containing an init.py file. When a regular package is imported, this</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:multiple_versions?rev=1687427196&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-06-22T09:46:36+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Multiple python versions</title>
        <link>http://192.168.180.206:8001/programming:python:multiple_versions?rev=1687427196&amp;do=diff</link>
        <description>Multiple python versions

pyenv

	*  &lt;https://realpython.com/intro-to-pyenv/&gt;
	*  &lt;https://askubuntu.com/questions/682869/how-do-i-install-a-different-python-version-using-apt-get&gt;

Installation

For fully automated installation: 

curl https://pyenv.run | bash

Manual installation steps:


git clone https://github.com/pyenv/pyenv.git ~/.pyenv

echo &#039;export PYENV_ROOT=&quot;$HOME/.pyenv&quot;&#039; &gt;&gt; ~/.bashrc
echo &#039;command -v pyenv &gt;/dev/null || export PATH=&quot;$PYENV_ROOT/bin:$PATH&quot;&#039; &gt;&gt; ~/.bashrc
echo &#039;eval &quot;$…</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:oop?rev=1704278068&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-01-03T10:34:28+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>OOP</title>
        <link>http://192.168.180.206:8001/programming:python:oop?rev=1704278068&amp;do=diff</link>
        <description>OOP

special methods

&lt;https://docs.python.org/3/reference/datamodel.html#special-method-names&gt;

	*  __new__
	*  __init__ - called after the instance has been created by new
	*  __del__ - finalizer: called when the instance is about to be destroyed.
		*  It is not guaranteed that del() methods are called for objects that still exist when the interpreter exits.</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:packaging?rev=1743529986&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-04-01T17:53:06+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Packaging</title>
        <link>http://192.168.180.206:8001/programming:python:packaging?rev=1743529986&amp;do=diff</link>
        <description>Packaging

PEP 517 – A build-system independent format for source trees
PEP 518 – Specifying Minimum Build System Requirements for Python Projects

	*  hatchling is the extensible, standards compliant build backend used by Hatch. Hatch is a modern, extensible Python project manager.
		*  &lt;https://packaging.python.org/en/latest/key_projects/#hatch&gt;
		*  &lt;https://pypi.org/project/hatchling/&gt;
		*  &lt;https://hatch.pypa.io/latest/config/build/&gt;

	*  flit provides a simple way to create and upload pure…</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:pip?rev=1744293869&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-04-10T14:04:29+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>pip</title>
        <link>http://192.168.180.206:8001/programming:python:pip?rev=1744293869&amp;do=diff</link>
        <description>pip

parallel install


xargs --max-args=1 --max-procs=4 sudo pip install &lt; requires.txt


error: externally-managed-environment


$ pip3 install yamllint
error: externally-managed-environment
× This environment is externally managed
╰─&gt; To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv…</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:pipx?rev=1760457974&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-14T16:06:14+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>pipx</title>
        <link>http://192.168.180.206:8001/programming:python:pipx?rev=1760457974&amp;do=diff</link>
        <description>pipx

Install requirements:


pipx install sphinx --verbose --include-deps
pipx runpip --verbose sphinx install -r doc/requirements.txt
pipx ensurepath


Install given commit directly from source git repo:


pipx install &#039;git+https://github.com/mxmlnkn/ratarmount.git@3e079a3&#039; -f</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:run_system_command?rev=1708674371&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-23T07:46:11+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>system / popen / exec</title>
        <link>http://192.168.180.206:8001/programming:python:run_system_command?rev=1708674371&amp;do=diff</link>
        <description>system / popen / exec

In general: run system commands.

Current recommended way is to use subprocess module. This module intends to replace several older modules and functions:


os.system
os.spawn*


Replacing Older Functions with the subprocess Module

Replacing os.system()

Features:

	*  possible to execute in shell:
		*  all command and params can be specified as string not list</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:socket?rev=1703769785&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-12-28T13:23:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>socket</title>
        <link>http://192.168.180.206:8001/programming:python:socket?rev=1703769785&amp;do=diff</link>
        <description>socket

socket — Low-level networking interface

socket.makefile

socket.makefile

When accessing socket as file:

	*  remember to call file.flush() after file.write()
	*  read() reads until EOF, so EOF for sockets means that connection is closed. Workarounds:
		*  use \n at end of message and readline()</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:sys?rev=1704127935&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-01-01T16:52:15+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>sys</title>
        <link>http://192.168.180.206:8001/programming:python:sys?rev=1704127935&amp;do=diff</link>
        <description>sys

sys.exit()

Always use sys.exit() to exit in production code. Built-in&#039;s like quit or exit can be omitted in some envs.

os._exit()

os._exit(n) Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.

Note: The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:tinyrpc?rev=1704131341&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-01-01T17:49:01+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>tinyrpc</title>
        <link>http://192.168.180.206:8001/programming:python:tinyrpc?rev=1704131341&amp;do=diff</link>
        <description>tinyrpc

exception

JSON-RPC 2.0 5.1 Error object

Adding custom exceptions

By default dispatcher catches all exceptions in registered methods: &lt;https://github.com/mbr/tinyrpc/blob/1.1.4/tinyrpc/dispatch/__init__.py#L266&gt;


        except Exception as e:
            # an error occurred within the method, return it
            return request.error_respond(e)


and exception e is wrapped as response using</description>
    </item>
    <item rdf:about="http://192.168.180.206:8001/programming:python:venv?rev=1722525181&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-08-01T15:13:01+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>venv</title>
        <link>http://192.168.180.206:8001/programming:python:venv?rev=1722525181&amp;do=diff</link>
        <description>venv

Makefile wrap


VENV_DIR ?= $(PWD)/.venv
WEST ?= $(VENV_DIR)/bin/west

$(VENV_DIR): zephyr/scripts/requirements.txt ;
	python3 -m venv $(VENV_DIR)
	$(VENV_DIR)/bin/pip install --upgrade west
	$(VENV_DIR)/bin/pip install -r zephyr/scripts/requirements.txt
	touch $(VENV_DIR)

init: $(VENV_DIR)
	[ -d &quot;.west&quot; ] || $(WEST) init -l app
	$(WEST) update
	$(WEST) patch --apply

menuconfig: build
	$(WEST) build -d $(BUILD_DIR) -t menuconfig</description>
    </item>
</rdf:RDF>
