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.2.tar.gz (4.2 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.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xpyutils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 354a647a3a8ccaca7f9b5dbea873f8625a969b38f6682003d2ef2dc39b98352a
MD5 8a94dde0f90689fb10a7d0b691633653
BLAKE2b-256 91b8f331ed7bf5681a87ffb54582cbfe80d1e8c6d9d14168d7a20bcb9b79bbe5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xpyutils-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a0e06dabfe801c9eb0058f5f4deea8efeb462f887a04eaa2be2f460e8edbe21c
MD5 0e0c4787c6d694dd02e882154c0bd175
BLAKE2b-256 41604a59af53807848e9916379d5b5106c2ddb0184d8ad81839a3d51098f6e4f

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