### Basic Process Start Example (Fails with Spawn/Forkserver) Source: https://docs.python.org/3.12/library/multiprocessing.html This example demonstrates a basic `multiprocessing.Process` setup. It will fail with `RuntimeError` when using `_spawn_` or `_forkserver_` start methods due to unsafe importing of the main module. ```python from multiprocessing import Process def foo(): print('hello') p = Process(target=foo) p.start() ``` -------------------------------- ### Setup virtual environment and install package Source: https://docs.python.org/3.12/library/importlib.metadata.html Commands to create a virtual environment and install a package for metadata inspection. ```bash $ python -m venv example $ source example/bin/activate (example) $ python -m pip install wheel ``` -------------------------------- ### Example PATH environment variable configuration Source: https://docs.python.org/3.12/using/windows.html A sample PATH string showing the inclusion of the Python installation directory delimited by a semicolon. ```text C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.9 ``` -------------------------------- ### Run an HTTP server Source: https://docs.python.org/3.12/library/http.server.html Example of how to instantiate and start an HTTP server using a specified server class and request handler class. ```python def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler): server_address = ('', 8000) httpd = server_class(server_address, handler_class) httpd.serve_forever() ``` -------------------------------- ### Distutils Setup with Classifiers Source: https://docs.python.org/3.12/whatsnew/2.3.html An example `setup.py` demonstrating how to use the `classifiers` keyword argument in Distutils for package metadata. This helps classify software for better discoverability on PyPI. ```python from distutils import core kw = {"name": "Quixote", "version": "0.5.1", "description": "A highly Pythonic Web application framework", # ... } if (hasattr(core, 'setup_keywords') and 'classifiers' in core.setup_keywords): kw['classifiers'] = ['Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Environment :: No Input/Output (Daemon)', 'Intended Audience :: Developers'], core.setup(**kw) ``` -------------------------------- ### GET Request Example Source: https://docs.python.org/3.12/library/http.client.html Example session demonstrating a GET request and reading the response. ```APIDOC ## GET Request Example Here is an example session that uses the `GET` method: ```python >>> import http.client >>> conn = http.client.HTTPSConnection("www.python.org") >>> conn.request("GET", "/") >>> r1 = conn.getresponse() >>> print(r1.status, r1.reason) 200 OK >>> data1 = r1.read() # This will return entire content. >>> # The following example demonstrates reading data in chunks. >>> conn.request("GET", "/") >>> r1 = conn.getresponse() >>> while chunk := r1.read(200): ... print(repr(chunk)) ... b'\n