Code

Python, Linux, APIs, Git, Software Standards and Artificial Intelligence

David Elboth | Updated November 2026

From C and Unix to Python and AI

I have worked with computers, software development and IT architecture for many years. My experience spans everything from early Unix and C programming to modern Python applications, REST APIs, graphical interfaces and artificial intelligence.

Over the years, I have written several books and hundreds of articles covering information technology, programming, Linux, system architecture and science.

Today, most of my own software development is done in Python, often combining several areas that particularly interest me: astrophysics, renewable energy, data analysis and artificial intelligence.

I still enjoy writing code, experimenting with new technology and solving practical problems.

My philosophy is quite simple:

Good software should be understandable, maintainable, secure and useful.

This page provides an introduction to my coding practices, current projects and selected code examples.

1. Python – My Primary Development Language

Python has become my preferred language for most new projects.

I use it for:

  • Monitoring solar installations, batteries and inverters.

  • Communicating with REST APIs and processing JSON data.

  • Building desktop applications with PyQt6.

  • Scientific calculations and astronomical applications.

  • Automation, reporting and data analysis.

  • Experimenting with locally hosted AI and large language models.

I develop across macOS, Linux and Windows. Where possible, I want the same Python source code to work on all three platforms.

For this reason, I prefer Python’s standard library wherever practical, alongside established libraries such as requests, PyQt6, NumPy, Astropy and pytest when a project requires them.

A simple Python application

Here is a basic starting point for a small, well-structured program.

#!/usr/bin/env python3
"""
File: main.py
Description: A simple Python application
Author: David Elboth
Version: 1.0.0
"""

from datetime import datetime


def get_message(name: str) -> str:
    """Return a personalised greeting."""
    return f"Hello, {name}! Welcome to Python."


def main() -> None:
    """Run the application."""
    print(get_message("World"))
    print(f"Started: {datetime.now():%Y-%m-%d %H:%M:%S}")


if __name__ == "__main__":
    main()

Although this example is very simple, it demonstrates some of the conventions I prefer: clear function names, type hints, docstrings and a dedicated entry point.

For a larger application, I normally separate the user interface, business logic, configuration and external API communication into different modules.

2. Working with REST APIs and JSON

Many of my projects communicate with external devices and services through APIs.

One example is monitoring solar energy systems, where I collect information such as battery state of charge, voltage, energy production and consumption.

A simple Python example shows how to retrieve JSON data using the standard library.

#!/usr/bin/env python3
"""
File: api_example.py
Description: Basic REST API and JSON example
Author: David Elboth
Version: 1.0.0
"""

import json
import logging
from urllib.error import HTTPError, URLError
from urllib.request import urlopen

API_URL = "https://jsonplaceholder.typicode.com/todos/1"

logging.basicConfig(level=logging.INFO)


def fetch_data(url: str) -> dict:
    """Fetch a JSON object from an HTTPS endpoint."""
    with urlopen(url, timeout=10) as response:
        data = json.load(response)

    if not isinstance(data, dict):
        raise ValueError("Expected a JSON object")

    return data


def main() -> None:
    """Retrieve and display example API data."""
    try:
        result = fetch_data(API_URL)
        print(json.dumps(result, indent=4))

    except (HTTPError, URLError, TimeoutError,
            ValueError, OSError) as error:
        logging.error("API request failed: %s", error)


if __name__ == "__main__":
    main()

This example uses a public demonstration API, not a real energy installation. It requires an internet connection.

In production applications, I also consider authentication, retries, rate limits, error responses and validation of returned data.

Never place API keys, passwords or authentication tokens directly in published source code. Use secure configuration methods or environment variables, and avoid logging sensitive information.

3. Python Coding Standards and Best Practices

Code quality matters, particularly when an application grows beyond a few hundred lines.

For my Python projects, I use the following principles.

Naming and structure

  • Follow PEP 8 for Python code style.

  • Use snake_case for functions and variables.

  • Use PascalCase for class names.

  • Use UPPER_CASE for module-level constants.

  • Prefer four spaces for indentation rather than tabs.

  • Keep functions reasonably small and focused.

  • Use type hints where they improve readability.

  • Add short docstrings explaining the purpose of functions and classes.

  • Avoid unnecessary complexity.

Documentation

Each project should have a README.md explaining its purpose, requirements, installation and use.

Larger projects may also need architecture notes, API documentation, examples and a changelog.

I prefer meaningful comments explaining why something is done rather than repeating what the code already says.

Reliability and testing

I use testing and validation to reduce errors and make future changes safer.

Useful tools include:

  • pytest for automated testing.

  • ruff for linting and formatting.

  • logging for diagnostic information.

  • venv for isolated Python environments.

  • pathlib for portable file handling.

  • pyproject.toml for project metadata and tool configuration.

The goal is not to introduce as many tools as possible. It is to choose the right ones for each project.

For further reading, see the official Python documentation, PEP 8 and the Python Packaging User Guide.

4. Git, GitHub and Version Management

Git is an important part of my development workflow.

It allows me to keep track of changes, compare versions, experiment with new features and restore an earlier working version if necessary.

Basic Git commands

# Create a local repository
git init

# Check changed files
git status

# Stage selected changes
git add main.py README.md

# Commit the changes
git commit -m "Add initial Python application"

# Create a feature branch
git switch -c feature/api-support

# View recent commits
git log --oneline

These commands work on macOS, Linux and Windows when Git is installed.

I also recommend creating a .gitignore file to exclude virtual environments, temporary files and local secrets from the repository.

Software version numbers

For projects with a defined release interface, I often recommend Semantic Versioning, using three numbers:

MAJOR.MINOR.PATCH

For example:

  • 1.0.0 – First stable release.

  • 1.0.1 – Backwards-compatible bug fix.

  • 1.1.0 – New backwards-compatible functionality.

  • 2.0.0 – Change that breaks compatibility.

Not every personal script needs formal Semantic Versioning. For smaller programs, Git commits and descriptive release tags may be sufficient.

A simple changelog helps explain what changed between versions.

See the Git documentation and Semantic Versioning.

5. Application Structure and Deployment

A Python project might use the following structure:

energy-monitor/
├── README.md
├── pyproject.toml
├── .gitignore
├── src/
│   └── energy_monitor/
│       ├── __init__.py
│       ├── main.py
│       ├── api_client.py
│       ├── config.py
│       └── monitoring.py
└── tests/
    └── test_monitoring.py

Separating the application into modules makes testing, maintenance and future expansion easier.

Virtual environments

I normally create a separate Python environment for each project.

python -m venv .venv

Activate it on macOS or Linux:

source .venv/bin/activate

Or on Windows PowerShell:

.\.venv\Scripts\Activate.ps1

The precise Python command may vary by installation; Windows installations may use py instead of python.

Once the environment is active, dependencies can be installed with python -m pip.

For desktop applications, I often use PyQt6. I also work with PyInstaller to package Python applications for their respective operating systems.

Data and configuration files should be stored in appropriate user-data directories rather than inside application binaries.

6. Real Projects – Where I Use Python

Solar Energy Monitoring – Victron and Solis

Renewable energy systems are one of my principal areas of practical software development.

I have built and operated several off-grid installations as well as an on-grid solar installation.

This experience has provided an excellent environment for developing my own monitoring and analysis applications.

For Victron systems, I have developed Python software that retrieves operational information through the Victron VRM API and presents it in a graphical interface.

My work also includes software for analysing data from solar installations using Solis equipment.

These projects bring together several interests: energy technology, communication protocols, Python programming and practical engineering.

Read more:

How the Victron Monitoring Application Was Built

My Off-Grid Energy Systems

Solar Energy and Energy Systems – My UK Book

Astronomy and Scientific Programming

With my academic background in astrophysics, I also enjoy scientific programming.

Python provides a powerful environment for astronomical calculations, particularly when combined with libraries such as NumPy and Astropy.

My interests include celestial calculations, scientific models and software performance.

Local Artificial Intelligence and Code Optimisation

I have also been experimenting with local large language models and their use as programming assistants.

One particularly interesting project combines a Mac development environment with a Windows computer running local AI models through Ollama.

The objective is to analyse Python code, suggest improvements, test the results and compare performance.

I find AI useful as an additional development tool, but generated code must still be reviewed and tested.

A faster function is of little value if it produces incorrect results.

Read more:

How I Built a Multi-OS AI Rig to Auto-Optimise My Python Code

How a Single Modelfile Saves Me Hours of Prompt Engineering

7. Other Programming Languages

Although Python is my principal language today, my development background covers several other languages and technologies.

Kotlin and Java

I have worked with Java and Kotlin, including REST API communication, HTTP clients, JSON data and enterprise applications.

Kotlin is especially interesting because of its concise syntax and interoperability with Java.

Official Kotlin documentation

Bash and Linux

Linux has been part of my professional work for many years.

I have used shell scripting for automation, system administration, file handling and development environments.

Bash remains valuable for simple automation, although I generally prefer Python for larger or more complex cross-platform applications.

GNU Bash Reference Manual

C Programming

C was an important language in my earlier software development.

In my book Linux server- og utviklingsmiljø, I described coding conventions covering naming, indentation, function structure and documentation.

Some conventions were designed for particular development environments and should be understood in their historical context.

For new C projects, I recommend following a documented project-specific style, using modern compiler diagnostics and applying appropriate secure-coding guidance.

SEI CERT C Coding Standard

8. My Approach to Software Development

Over many years in IT, I have seen programming languages, hardware platforms and development tools change dramatically.

Some fundamental principles have remained surprisingly constant.

Software should solve a real problem.

It should be understandable to someone other than the original developer.

It should handle errors, protect sensitive information and be documented well enough to maintain.

And, perhaps most importantly, it should be tested.

Artificial intelligence is now changing how we write and review code. I expect it to become an increasingly important part of software development.

However, I still believe that understanding the problem, choosing the right architecture and verifying the result are more important than simply generating more code.

That is the approach I try to follow in my own projects.


David Elboth

Astrophysics, software development, IT architecture and renewable energy systems.