Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xpyutils

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xpyutils

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

  • 0.0.4
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc