UUID (PyPI Backport for Python 2.x)

1.30 · deprecated · verified Fri Apr 10

This PyPI package (version 1.30) provides a backport of the `uuid` module's functionality for older Python versions, specifically 2.3 through 2.5. For Python 2.6 and newer, the `uuid` module is included in the Python standard library and this PyPI package is generally not needed. It was last released in 2006 and is not actively maintained.

Warnings

Install

Imports

Quickstart

Demonstrates generating version 1 and version 4 UUIDs, and reconstructing a UUID object from its string representation using the PyPI `uuid` package, which mirrors the standard library's API for older Python versions.

import uuid

# Generate a random UUID (version 4)
new_uuid = uuid.uuid4()
print(f"Generated UUID (version 4): {new_uuid}")
print(f"UUID as hex string: {new_uuid.hex}")

# Generate a time-based UUID (version 1)
# Note: uuid1() may expose the computer's MAC address.
time_uuid = uuid.uuid1()
print(f"Generated UUID (version 1): {time_uuid}")

# Reconstruct a UUID from a string
from uuid import UUID
recovered_uuid = UUID(str(new_uuid))
print(f"Recovered UUID: {recovered_uuid}")
print(f"Are they equal? {new_uuid == recovered_uuid}")

view raw JSON →