Skip to main content

61 posts tagged with "python"

python tag description

View All Tags

Cloning a list in Python

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Cloning a list in Python is essential to avoid unintended side effects, as simply assigning one list to another with the equals sign (=) creates a reference, not a new copy [1]. This means both variables point to the same list object in memory, and modifying one will modify the other. To properly clone a list, you need to understand the difference between a shallow copy and a deep copy.

Choosing the right Python environment and package management tool in 2025

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Choosing the right Python environment and package management tool in 2025 depends on your project's complexity and your team's workflow. The tools available can be categorized into two main groups: those that manage Python versions (pyenv, asdf) and those that manage project dependencies (venv, virtualenv, Poetry). Combining these tools is often the most effective approach.

Python's @property vs. @classmethod - A No-Nonsense Guide

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

When you're diving into Python's Object-Oriented Programming (OOP) features, decorators like @property and @classmethod pop up all the time. They might seem similar at first glance, but they serve fundamentally different purposes. Getting them straight is key to writing clean, Pythonic code.

Let's cut through the noise and get straight to what they do and when you should use them.

Managing database queries in Django applications and where save the queries

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

As a Django app grows, managing database queries effectively is crucial for maintainability, performance, and testability. Storing them haphazardly is a recipe for disaster. The best place to store your queries is on custom Model Managers and QuerySets. This approach keeps your logic organized, reusable, and closely tied to the data it operates on. Here are the main variants for storing your queries, from the least recommended to the best practice.

Testing hello world function in python with doctests

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Sometimes even the simplest programs deserve solid testing-especially when you're working in a team or trying to set strong standards for code quality. In this note, we'll take the most basic example-"Hello, World!"-and build out everything around it to demonstrate how doctests can be used effectively, even for something so trivial. The goal is to build intuition for testing, not just solve a toy problem.

Various Ways for Executing Doctests in Python

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Executing Doctests in Python: A Comprehensive Guide​

Doctest is a module in the Python Standard Library that enables you to write tests within the documentation of your code-typically inside docstrings. These tests look like interactive Python sessions (as if they were run in a Python shell), and the doctest module verifies that the output matches the expected result. While doctests are generally simpler than unit tests written with unittest or pytest, they are powerful for checking that code examples in documentation remain correct over time.

This guide explores the various ways to execute doctests in Python, from running them via the command line to embedding them in code and running them programmatically.

How to Make Doctests Easy in Python with Gitpod and VS Code

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

If you're writing doctests in Python using Gitpod or VS Code, you don’t need much to get started. Python’s built-in doctest module lets you write examples in your function’s docstring using the familiar >>> prompt, and then run those examples as tests. This is great for small, focused functions or when you want your documentation to double as lightweight tests.

How to Easily Write Docstrings in Python Without a Headache (Using VSCode)

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Writing docstrings in Python can feel like a chore - especially with the odd formatting involving triple quotes, >>> signs, and parameter blocks. But clear, standardized docstrings are critical for both readability and maintainability.

If you’re using VSCode (Visual Studio Code), you’re in luck. With a few extensions and configurations, you can make writing professional, PEP 257-compliant docstrings painless.