Hybrid-Attributes
Hybrid-Attributes implements a hybrid_property and hybrid_method descriptor, which call the underlying function both in a class and instance context.
Assume you have a class like:
class Foo:
@classmethod
def spam(self):
return 'spam'
@property
def eggs(self):
return 'eggs'
def ham(self):
return 'ham'
You can get the values returned by calling .spam() on the class, accessing ‘.eggs’ or calling .ham() on an instance:
>>> Foo.spam() 'spam' >>> foo = Foo() >>> foo.eggs 'eggs' >>> foo.ham() 'ham'
If you access these in a different context, .spam() will still be called with the class as first argument, .eggs will return a property object only useful for introspection and .ham() will raise an exception because there is no instance for it to be called with.
Hybrid-Attributes are different. They don’t care about the object are accessed through, the underlying function will always be called with whatever object it’s being accessed on. As an example, take this class:
class HybridFoo:
@hybrid_property
def spam(self):
return 'spam'
@hybrid_method
def eggs(self):
return 'eggs'
You can access the property and call the method on the class or on an instance:
>>> Foo.spam 'spam' >>> Foo.eggs() 'eggs' >>> foo = Foo() >>> foo.spam 'spam' >>> foo.eggs
Hybrid-Attributes is BSD licensed and available for Python 3.4 and later.
Metadata
Release files for hybrid-attributes 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hybrid-attributes-0.1.0.tar.gz | 11.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hybrid_attributes-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 16.8 kB
Release files / hybrid-attributes-0.1.0.tar.gz
| Download URL | hybrid-attributes-0.1.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
225d359527abd504de2481e2326fb1b5dab8ac1a371488197efbc4c4c3516a9e
|
|
BLAKE2b-256 checksum How to use checksums |
db405fdc85654f40abd47222129b84e987166d3c97ee39f24cbb379adc758b29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / hybrid_attributes-0.1.0-py2.py3-none-any.whl
| Download URL | hybrid_attributes-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
86690cfbb9546fbd3a51268ee66ab1d7888d7d6db3c88bf6a5c5ebf3c71ddd49
|
|
BLAKE2b-256 checksum How to use checksums |
90388a08a1252eeb58a8d9b9d32a9ee6f4b22ac64dcf9613fa87547f5c338eb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for hybrid-attributes 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.