Skip to main content

Extra Python Utilities

🛠️ Ongoing project of extra Python utilities including implementation of lazy property, collections of common regular expressions, ...

Lazy Property

A simple use of lazy_property:

from xpyutils import lazy_property

import random
random.seed(42)

class Person:
    
    def __init__(self, name: str) -> None:
        self._name = name
    
    @property
    def name(self) -> str:
        """Name of the person.
        """
        return self._name
    
    @lazy_property
    def lucky_number(self) -> int:
        """Lucky number.
        """
        return random.randint(0, 100)
    
    @lazy_property.require_presence()
    def age(self) -> int:
        """Age.
        """
        return random.randint(20, 30)
    
person = Person('Isaac')

print(person.lucky_number) # 81
print(person.lucky_number) # it is still 81

try: 
    person.age
except Exception as e:
    print(e) # property 'age' is not present yet

Metadata

Release files for xpyutils 0.0.4

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

Source distribution (sdist)

Source distribution for xpyutils 0.0.4
File Size Uploaded
xpyutils-0.0.4.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xpyutils 0.0.4
File Interpreter ABI Platform
xpyutils-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / xpyutils-0.0.4.tar.gz

Download URL xpyutils-0.0.4.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
66da7fe58a1697e9af92dd5145a3c9bc9fcf9b6e17bd1bf758493f1ef040e2fa
BLAKE2b-256 checksum
How to use checksums
597c524e45b5c8269892977cd0d143924d228ab0a24bcdd15d6de1c3355275f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / xpyutils-0.0.4-py3-none-any.whl

Download URL xpyutils-0.0.4-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
922187d74451beb4d3bfb737447b0bad3543064257eac98e2d312e8d438c79fb
BLAKE2b-256 checksum
How to use checksums
f655434d4600d1032707d73083322268fefacb911cf498060b6d1136674e2974
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

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