Skip to main content

Ongoing project of extra Python utilities including implementations of lazy property, regular expression, ...

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpyutils-0.0.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xpyutils-0.0.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file xpyutils-0.0.4.tar.gz.

File metadata

  • Download URL: xpyutils-0.0.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for xpyutils-0.0.4.tar.gz
Algorithm Hash digest
SHA256 66da7fe58a1697e9af92dd5145a3c9bc9fcf9b6e17bd1bf758493f1ef040e2fa
MD5 23361cc14d4e409d7f351a831a853d97
BLAKE2b-256 597c524e45b5c8269892977cd0d143924d228ab0a24bcdd15d6de1c3355275f9

See more details on using hashes here.

File details

Details for the file xpyutils-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: xpyutils-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for xpyutils-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 922187d74451beb4d3bfb737447b0bad3543064257eac98e2d312e8d438c79fb
MD5 30fbff12b4491e47e57e1bf60cb32d5a
BLAKE2b-256 f655434d4600d1032707d73083322268fefacb911cf498060b6d1136674e2974

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page