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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66da7fe58a1697e9af92dd5145a3c9bc9fcf9b6e17bd1bf758493f1ef040e2fa
|
|
| MD5 |
23361cc14d4e409d7f351a831a853d97
|
|
| BLAKE2b-256 |
597c524e45b5c8269892977cd0d143924d228ab0a24bcdd15d6de1c3355275f9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
922187d74451beb4d3bfb737447b0bad3543064257eac98e2d312e8d438c79fb
|
|
| MD5 |
30fbff12b4491e47e57e1bf60cb32d5a
|
|
| BLAKE2b-256 |
f655434d4600d1032707d73083322268fefacb911cf498060b6d1136674e2974
|