UniCoreFW

unique_id()

Generate a unique identifier with an optional prefix.

Implementation

This function uses a global counter to ensure uniqueness within a single process. Args: prefix: Optional prefix for the ID Returns: A unique string identifier

Example

unique_id("user-")

Expected output: "user-1"

Alternative usage:

unique_id("user-")

Expected output: "user-2"

Source Code

def unique_id(prefix: str = "") -> str: # This is a module-level function, so we need to access the class variable directly # from the UniCoreFW class. This will be properly imported and resolved at runtime. from .core import UniCoreFW UniCoreFW._id_counter += 1 return f"{prefix}{UniCoreFW._id_counter}"