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.3.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.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xpyutils-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 f8f38d944dd37af981e2c2fe9c9a520037e715e7bac22b3d122e52fbbf5665fe
MD5 90e10ee6a7fbd369e9e5d573aad734c3
BLAKE2b-256 0ff9104a05c96ae535649f26fd1ede0e2be12f335d2ae6a3d299f140c5af3331

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpyutils-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc3a2c8877f2d7cc9dbf57a5eb07d2f896e8a295653119da68d71f3dae74393f
MD5 91557168c3f8c0490ee0501261988ad6
BLAKE2b-256 9a779d2b3051a2b5913106b67eade152b5da5fbe3f519bd7200f48e37d603650

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