Skip to main content

Version Class (Python Implementation)

A Python implementation of version number management inspired by .NET's Version class, providing robust version number handling and comparison capabilities.

Features

  • Multiple constructors for flexible version creation
  • String parsing and validation
  • Component-based comparison operations
  • Strict type and value checking
  • Comprehensive error handling

Installation

pip install model_version_manager

Basic Usage

from model_version_manager import Version

# Different ways to create versions
v1 = Version()           # 0.0
v2 = Version(1, 2)       # 1.2
v3 = Version(1, 2, 3)    # 1.2.3
v4 = Version("1.2.3.4")  # From string

# Access components
print(f"{v4.major}.{v4.minor}.{v4.build}.{v4.revision}")

# Comparison
print(v2 == Version(1, 2))  # True
print(v3 < Version(1, 3))   # True
print(v1 > v2)              # False

API Reference

Version()   # 0.0
Version(major: int, minor: int) 
Version(major: int, minor: int, build: int) 
Version(major: int, minor: int, build: int, revision: int)
Version(version_string: str)  # Parses "major.minor.build.revision"

Properies

  • major: int - Major version number

  • minor: int - Minor version number

  • build: int - Build number (-1 if not specified)

  • revision: int - Revision number (-1 if not specified)

Methods

  • __str__(): Returns string representation (e.g. "1.2.3.4")

  • __eq__(), __lt__(), etc.: Comparison operators

  • parse(version_string): Classmethod to parse version strings

Comparison Rules

Versions are compared component by component in order:

  1. Major

  2. Minor

  3. Build

  4. Revision

Missing components (represented by -1) are considered older than any specified component.

Examples

See complete examples in the examples/ directory:

  • basic_usage.py - Basic functionality

Release files for model-version-manager 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for model-version-manager 1.0.1
File Size Uploaded
model_version_manager-1.0.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for model-version-manager 1.0.1
File Interpreter ABI Platform
model_version_manager-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / model_version_manager-1.0.1.tar.gz

Download URL model_version_manager-1.0.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
20aa33a749ab0e649cab9bfacc67331e4fc80ea62f85be96a21a73b7040faf69
BLAKE2b-256 checksum
How to use checksums
b5b440f92e2dd4365fc8e1464741fce4afbc88269b5057029f7a6c9a0f14aeac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release files / model_version_manager-1.0.1-py3-none-any.whl

Download URL model_version_manager-1.0.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcc83dae8d3fc4f83713edebe61354d3c4ddcfa382850b58455b9cd4e4d0ba86
BLAKE2b-256 checksum
How to use checksums
110aad81713b673c0d9cae14bae0cc428d33dc7764f00cb2bb9f44a8dabccaef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page