@export decorator that adds a function or class to __all__
Project description
@exports
The DRY alternative to __all__
Installation
To install the exports package, you can use
python-exports on PyPI:
pip install python-exports
Usage
>>> from exports import export
Now you can use it to add to __all__ as
-
function decorator
>>> @export ... def spam(): ... ...
-
class decorator:
>>> @export ... class Ham: ... ...
-
by name:
>>> from functools import reduce as fold >>> export('fold')
Behaviour
If the module has no __all__, it is created.
Otherwise, __all__ is converted to a list, and the export is appended.
Caveats
Exporting a function or class directly relies on the __name__ attribute,
so consider the following example:
>>> def eggs():
... ...
>>> fake_eggs = eggs
If we want to export fake_eggs, then this will not work:
>>> export(fake_eggs) # BAD: this will add `'eggs'` to `__all__`
In such cases, use the name instead:
>>> export('fake_eggs') # GOOD
You'll be safe if you either
- decorate a function or a class directly with
@export, - pass the name string when using plain
export('...')calls.
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
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 python_exports-1.3.0.tar.gz.
File metadata
- Download URL: python_exports-1.3.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
124303d1f643b4e2c3bcbf5e1140f00da85b52c60bd11ce57f0104ae1dd0cad2
|
|
| MD5 |
93e1efa7266193eb4d58c61c333b03b4
|
|
| BLAKE2b-256 |
4d13e0c77bb1d951e59af8a455c7280642c7e48a93febafb56b17f0931ef4176
|
Provenance
The following attestation bundles were made for python_exports-1.3.0.tar.gz:
Publisher:
publish-pypi.yml on jorenham/exports
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_exports-1.3.0.tar.gz -
Subject digest:
124303d1f643b4e2c3bcbf5e1140f00da85b52c60bd11ce57f0104ae1dd0cad2 - Sigstore transparency entry: 813277814
- Sigstore integration time:
-
Permalink:
jorenham/exports@5d577f387bb9cc88751838f880a4822f8d2987d5 -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/jorenham
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5d577f387bb9cc88751838f880a4822f8d2987d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_exports-1.3.0-py3-none-any.whl.
File metadata
- Download URL: python_exports-1.3.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd1baafa2ced944a0df3baa79b78cb3e416f8dd9a10c329516de156d80ff3dc8
|
|
| MD5 |
36601abe4786c5bacab5d3c5b3172b89
|
|
| BLAKE2b-256 |
1a534f96521f0402fce3a8a3642a3d4868c7320bfd9a2741dfbaf4c2b8cce641
|
Provenance
The following attestation bundles were made for python_exports-1.3.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on jorenham/exports
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_exports-1.3.0-py3-none-any.whl -
Subject digest:
bd1baafa2ced944a0df3baa79b78cb3e416f8dd9a10c329516de156d80ff3dc8 - Sigstore transparency entry: 813277815
- Sigstore integration time:
-
Permalink:
jorenham/exports@5d577f387bb9cc88751838f880a4822f8d2987d5 -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/jorenham
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5d577f387bb9cc88751838f880a4822f8d2987d5 -
Trigger Event:
push
-
Statement type: